| @@ -4,6 +4,7 @@ public sealed class MessageDto : BaseDto | |||
| { | |||
| public string Text { get; set; } | |||
| public bool IsValid { get; set; } = true; | |||
| public Guid Code { get; set; } = Guid.NewGuid(); | |||
| public string FileName { get; set; } | |||
| public DateTime? ExpiryDate { get; set; } | |||
| } | |||
| @@ -6,12 +6,13 @@ namespace SecureSharing.Business.Interfaces; | |||
| public interface IMessageService | |||
| { | |||
| public Task<IEnumerable<MessageDto>> GetAll(); | |||
| public Task<int> Create(MessageDto messageDto, PeriodOfValidity chosenPeriod); | |||
| public Task<Guid> Create(MessageDto messageDto, PeriodOfValidity chosenPeriod); | |||
| public Task DeleteExpiredMessages(); | |||
| public Task InvalidateMessage(int id); | |||
| public Task Update(MessageDto messageDto); | |||
| public Task<MessageDto> GetById(int messageDto); | |||
| public Task<MessageDto> GetByCode(Guid code); | |||
| public Task<bool> Delete(int messageDto); | |||
| } | |||
| @@ -19,7 +19,7 @@ public sealed class MessageService : IMessageService | |||
| _mapper = mapper; | |||
| } | |||
| public async Task<int> Create(MessageDto messageDto, PeriodOfValidity chosenPeriod) | |||
| public async Task<Guid> Create(MessageDto messageDto, PeriodOfValidity chosenPeriod) | |||
| { | |||
| var message = _mapper.Map<Message>(messageDto); | |||
| message.ExpiryDate = chosenPeriod switch | |||
| @@ -33,7 +33,7 @@ public sealed class MessageService : IMessageService | |||
| await _dbContext.Messages.AddAsync(message); | |||
| await _dbContext.SaveChangesAsync(); | |||
| return message.Id; | |||
| return Guid.Parse(message.Code); | |||
| } | |||
| public async Task DeleteExpiredMessages() | |||
| @@ -84,6 +84,13 @@ public sealed class MessageService : IMessageService | |||
| return mappedResult; | |||
| } | |||
| public async Task<MessageDto> GetByCode(Guid code) | |||
| { | |||
| var result = await _dbContext.Messages.AsNoTracking().FirstOrDefaultAsync(x => x.Code == code.ToString()); | |||
| var mappedResult = _mapper.Map<MessageDto>(result); | |||
| return mappedResult; | |||
| } | |||
| public async Task Update(MessageDto messageDto) | |||
| { | |||
| var a = _dbContext.Messages.Update(_mapper.Map<Message>(messageDto)); | |||
| @@ -3,6 +3,8 @@ | |||
| public sealed class Message : BaseEntity | |||
| { | |||
| public string Text { get; set; } | |||
| public string Code { get; set; } | |||
| public string FileName { get; set; } | |||
| public bool IsValid { get; set; } | |||
| public DateTime? ExpiryDate { get; set; } | |||
| } | |||
| @@ -0,0 +1,310 @@ | |||
| // <auto-generated /> | |||
| using System; | |||
| using Microsoft.EntityFrameworkCore; | |||
| using Microsoft.EntityFrameworkCore.Infrastructure; | |||
| using Microsoft.EntityFrameworkCore.Metadata; | |||
| using Microsoft.EntityFrameworkCore.Migrations; | |||
| using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | |||
| using SecureSharing.Data.DbContexts; | |||
| #nullable disable | |||
| namespace SecureSharing.Data.Migrations | |||
| { | |||
| [DbContext(typeof(AppDbContext))] | |||
| [Migration("20220927104345_AddingFileNameAndCode")] | |||
| partial class AddingFileNameAndCode | |||
| { | |||
| protected override void BuildTargetModel(ModelBuilder modelBuilder) | |||
| { | |||
| #pragma warning disable 612, 618 | |||
| modelBuilder | |||
| .HasAnnotation("ProductVersion", "6.0.9") | |||
| .HasAnnotation("Relational:MaxIdentifierLength", 128); | |||
| SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => | |||
| { | |||
| b.Property<string>("Id") | |||
| .HasColumnType("nvarchar(450)"); | |||
| b.Property<string>("ConcurrencyStamp") | |||
| .IsConcurrencyToken() | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.Property<string>("Name") | |||
| .HasMaxLength(256) | |||
| .HasColumnType("nvarchar(256)"); | |||
| b.Property<string>("NormalizedName") | |||
| .HasMaxLength(256) | |||
| .HasColumnType("nvarchar(256)"); | |||
| b.HasKey("Id"); | |||
| b.HasIndex("NormalizedName") | |||
| .IsUnique() | |||
| .HasDatabaseName("RoleNameIndex") | |||
| .HasFilter("[NormalizedName] IS NOT NULL"); | |||
| b.ToTable("AspNetRoles", (string)null); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b => | |||
| { | |||
| b.Property<int>("Id") | |||
| .ValueGeneratedOnAdd() | |||
| .HasColumnType("int"); | |||
| SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1); | |||
| b.Property<string>("ClaimType") | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.Property<string>("ClaimValue") | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.Property<string>("RoleId") | |||
| .IsRequired() | |||
| .HasColumnType("nvarchar(450)"); | |||
| b.HasKey("Id"); | |||
| b.HasIndex("RoleId"); | |||
| b.ToTable("AspNetRoleClaims", (string)null); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => | |||
| { | |||
| b.Property<string>("Id") | |||
| .HasColumnType("nvarchar(450)"); | |||
| b.Property<int>("AccessFailedCount") | |||
| .HasColumnType("int"); | |||
| b.Property<string>("ConcurrencyStamp") | |||
| .IsConcurrencyToken() | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.Property<string>("Email") | |||
| .HasMaxLength(256) | |||
| .HasColumnType("nvarchar(256)"); | |||
| b.Property<bool>("EmailConfirmed") | |||
| .HasColumnType("bit"); | |||
| b.Property<bool>("LockoutEnabled") | |||
| .HasColumnType("bit"); | |||
| b.Property<DateTimeOffset?>("LockoutEnd") | |||
| .HasColumnType("datetimeoffset"); | |||
| b.Property<string>("NormalizedEmail") | |||
| .HasMaxLength(256) | |||
| .HasColumnType("nvarchar(256)"); | |||
| b.Property<string>("NormalizedUserName") | |||
| .HasMaxLength(256) | |||
| .HasColumnType("nvarchar(256)"); | |||
| b.Property<string>("PasswordHash") | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.Property<string>("PhoneNumber") | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.Property<bool>("PhoneNumberConfirmed") | |||
| .HasColumnType("bit"); | |||
| b.Property<string>("SecurityStamp") | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.Property<bool>("TwoFactorEnabled") | |||
| .HasColumnType("bit"); | |||
| b.Property<string>("UserName") | |||
| .HasMaxLength(256) | |||
| .HasColumnType("nvarchar(256)"); | |||
| b.HasKey("Id"); | |||
| b.HasIndex("NormalizedEmail") | |||
| .HasDatabaseName("EmailIndex"); | |||
| b.HasIndex("NormalizedUserName") | |||
| .IsUnique() | |||
| .HasDatabaseName("UserNameIndex") | |||
| .HasFilter("[NormalizedUserName] IS NOT NULL"); | |||
| b.ToTable("AspNetUsers", (string)null); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b => | |||
| { | |||
| b.Property<int>("Id") | |||
| .ValueGeneratedOnAdd() | |||
| .HasColumnType("int"); | |||
| SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1); | |||
| b.Property<string>("ClaimType") | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.Property<string>("ClaimValue") | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.Property<string>("UserId") | |||
| .IsRequired() | |||
| .HasColumnType("nvarchar(450)"); | |||
| b.HasKey("Id"); | |||
| b.HasIndex("UserId"); | |||
| b.ToTable("AspNetUserClaims", (string)null); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b => | |||
| { | |||
| b.Property<string>("LoginProvider") | |||
| .HasMaxLength(128) | |||
| .HasColumnType("nvarchar(128)"); | |||
| b.Property<string>("ProviderKey") | |||
| .HasMaxLength(128) | |||
| .HasColumnType("nvarchar(128)"); | |||
| b.Property<string>("ProviderDisplayName") | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.Property<string>("UserId") | |||
| .IsRequired() | |||
| .HasColumnType("nvarchar(450)"); | |||
| b.HasKey("LoginProvider", "ProviderKey"); | |||
| b.HasIndex("UserId"); | |||
| b.ToTable("AspNetUserLogins", (string)null); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b => | |||
| { | |||
| b.Property<string>("UserId") | |||
| .HasColumnType("nvarchar(450)"); | |||
| b.Property<string>("RoleId") | |||
| .HasColumnType("nvarchar(450)"); | |||
| b.HasKey("UserId", "RoleId"); | |||
| b.HasIndex("RoleId"); | |||
| b.ToTable("AspNetUserRoles", (string)null); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b => | |||
| { | |||
| b.Property<string>("UserId") | |||
| .HasColumnType("nvarchar(450)"); | |||
| b.Property<string>("LoginProvider") | |||
| .HasMaxLength(128) | |||
| .HasColumnType("nvarchar(128)"); | |||
| b.Property<string>("Name") | |||
| .HasMaxLength(128) | |||
| .HasColumnType("nvarchar(128)"); | |||
| b.Property<string>("Value") | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.HasKey("UserId", "LoginProvider", "Name"); | |||
| b.ToTable("AspNetUserTokens", (string)null); | |||
| }); | |||
| modelBuilder.Entity("SecureSharing.Data.Data.Message", b => | |||
| { | |||
| b.Property<int>("Id") | |||
| .ValueGeneratedOnAdd() | |||
| .HasColumnType("int"); | |||
| SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1); | |||
| b.Property<string>("Code") | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.Property<DateTime?>("ExpiryDate") | |||
| .HasColumnType("datetime2"); | |||
| b.Property<string>("FileName") | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.Property<bool>("IsValid") | |||
| .HasColumnType("bit"); | |||
| b.Property<string>("Text") | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.HasKey("Id"); | |||
| b.ToTable("Messages"); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b => | |||
| { | |||
| b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) | |||
| .WithMany() | |||
| .HasForeignKey("RoleId") | |||
| .OnDelete(DeleteBehavior.Cascade) | |||
| .IsRequired(); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b => | |||
| { | |||
| b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) | |||
| .WithMany() | |||
| .HasForeignKey("UserId") | |||
| .OnDelete(DeleteBehavior.Cascade) | |||
| .IsRequired(); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b => | |||
| { | |||
| b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) | |||
| .WithMany() | |||
| .HasForeignKey("UserId") | |||
| .OnDelete(DeleteBehavior.Cascade) | |||
| .IsRequired(); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b => | |||
| { | |||
| b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) | |||
| .WithMany() | |||
| .HasForeignKey("RoleId") | |||
| .OnDelete(DeleteBehavior.Cascade) | |||
| .IsRequired(); | |||
| b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) | |||
| .WithMany() | |||
| .HasForeignKey("UserId") | |||
| .OnDelete(DeleteBehavior.Cascade) | |||
| .IsRequired(); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b => | |||
| { | |||
| b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) | |||
| .WithMany() | |||
| .HasForeignKey("UserId") | |||
| .OnDelete(DeleteBehavior.Cascade) | |||
| .IsRequired(); | |||
| }); | |||
| #pragma warning restore 612, 618 | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,35 @@ | |||
| using Microsoft.EntityFrameworkCore.Migrations; | |||
| #nullable disable | |||
| namespace SecureSharing.Data.Migrations | |||
| { | |||
| public partial class AddingFileNameAndCode : Migration | |||
| { | |||
| protected override void Up(MigrationBuilder migrationBuilder) | |||
| { | |||
| migrationBuilder.AddColumn<string>( | |||
| name: "Code", | |||
| table: "Messages", | |||
| type: "nvarchar(max)", | |||
| nullable: true); | |||
| migrationBuilder.AddColumn<string>( | |||
| name: "FileName", | |||
| table: "Messages", | |||
| type: "nvarchar(max)", | |||
| nullable: true); | |||
| } | |||
| protected override void Down(MigrationBuilder migrationBuilder) | |||
| { | |||
| migrationBuilder.DropColumn( | |||
| name: "Code", | |||
| table: "Messages"); | |||
| migrationBuilder.DropColumn( | |||
| name: "FileName", | |||
| table: "Messages"); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,10 +1,12 @@ | |||
| // <auto-generated /> | |||
| using System; | |||
| using SecureSharing.Data.DbContexts; | |||
| using Microsoft.EntityFrameworkCore; | |||
| using Microsoft.EntityFrameworkCore.Infrastructure; | |||
| using Microsoft.EntityFrameworkCore.Metadata; | |||
| using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | |||
| using SecureSharing.Data.DbContexts; | |||
| #nullable disable | |||
| namespace SecureSharing.Data.Migrations | |||
| { | |||
| @@ -15,30 +17,10 @@ namespace SecureSharing.Data.Migrations | |||
| { | |||
| #pragma warning disable 612, 618 | |||
| modelBuilder | |||
| .HasAnnotation("Relational:MaxIdentifierLength", 128) | |||
| .HasAnnotation("ProductVersion", "5.0.7") | |||
| .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); | |||
| .HasAnnotation("ProductVersion", "6.0.9") | |||
| .HasAnnotation("Relational:MaxIdentifierLength", 128); | |||
| modelBuilder.Entity("SecureSharing.Data.Data.Message", b => | |||
| { | |||
| b.Property<int>("Id") | |||
| .ValueGeneratedOnAdd() | |||
| .HasColumnType("int") | |||
| .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); | |||
| b.Property<DateTime?>("ExpiryDate") | |||
| .HasColumnType("datetime2"); | |||
| b.Property<bool>("IsValid") | |||
| .HasColumnType("bit"); | |||
| b.Property<string>("Text") | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.HasKey("Id"); | |||
| b.ToTable("Messages"); | |||
| }); | |||
| SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => | |||
| { | |||
| @@ -64,15 +46,16 @@ namespace SecureSharing.Data.Migrations | |||
| .HasDatabaseName("RoleNameIndex") | |||
| .HasFilter("[NormalizedName] IS NOT NULL"); | |||
| b.ToTable("AspNetRoles"); | |||
| b.ToTable("AspNetRoles", (string)null); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b => | |||
| { | |||
| b.Property<int>("Id") | |||
| .ValueGeneratedOnAdd() | |||
| .HasColumnType("int") | |||
| .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); | |||
| .HasColumnType("int"); | |||
| SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1); | |||
| b.Property<string>("ClaimType") | |||
| .HasColumnType("nvarchar(max)"); | |||
| @@ -88,7 +71,7 @@ namespace SecureSharing.Data.Migrations | |||
| b.HasIndex("RoleId"); | |||
| b.ToTable("AspNetRoleClaims"); | |||
| b.ToTable("AspNetRoleClaims", (string)null); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => | |||
| @@ -153,15 +136,16 @@ namespace SecureSharing.Data.Migrations | |||
| .HasDatabaseName("UserNameIndex") | |||
| .HasFilter("[NormalizedUserName] IS NOT NULL"); | |||
| b.ToTable("AspNetUsers"); | |||
| b.ToTable("AspNetUsers", (string)null); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b => | |||
| { | |||
| b.Property<int>("Id") | |||
| .ValueGeneratedOnAdd() | |||
| .HasColumnType("int") | |||
| .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); | |||
| .HasColumnType("int"); | |||
| SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1); | |||
| b.Property<string>("ClaimType") | |||
| .HasColumnType("nvarchar(max)"); | |||
| @@ -177,7 +161,7 @@ namespace SecureSharing.Data.Migrations | |||
| b.HasIndex("UserId"); | |||
| b.ToTable("AspNetUserClaims"); | |||
| b.ToTable("AspNetUserClaims", (string)null); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b => | |||
| @@ -201,7 +185,7 @@ namespace SecureSharing.Data.Migrations | |||
| b.HasIndex("UserId"); | |||
| b.ToTable("AspNetUserLogins"); | |||
| b.ToTable("AspNetUserLogins", (string)null); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b => | |||
| @@ -216,7 +200,7 @@ namespace SecureSharing.Data.Migrations | |||
| b.HasIndex("RoleId"); | |||
| b.ToTable("AspNetUserRoles"); | |||
| b.ToTable("AspNetUserRoles", (string)null); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b => | |||
| @@ -237,7 +221,35 @@ namespace SecureSharing.Data.Migrations | |||
| b.HasKey("UserId", "LoginProvider", "Name"); | |||
| b.ToTable("AspNetUserTokens"); | |||
| b.ToTable("AspNetUserTokens", (string)null); | |||
| }); | |||
| modelBuilder.Entity("SecureSharing.Data.Data.Message", b => | |||
| { | |||
| b.Property<int>("Id") | |||
| .ValueGeneratedOnAdd() | |||
| .HasColumnType("int"); | |||
| SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1); | |||
| b.Property<string>("Code") | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.Property<DateTime?>("ExpiryDate") | |||
| .HasColumnType("datetime2"); | |||
| b.Property<string>("FileName") | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.Property<bool>("IsValid") | |||
| .HasColumnType("bit"); | |||
| b.Property<string>("Text") | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.HasKey("Id"); | |||
| b.ToTable("Messages"); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b => | |||
| @@ -32,14 +32,14 @@ public sealed class HomeController : Controller | |||
| public async Task<IActionResult> CreateMessage(MessageModel model) | |||
| { | |||
| var message = new MessageDto { Text = model.Text }; | |||
| var id = await _messageService.Create(message, model.ChosenPeriod); | |||
| return RedirectToAction("Link", "Home", new { id, share = true }); | |||
| var code = await _messageService.Create(message, model.ChosenPeriod); | |||
| return RedirectToAction("Link", "Home", new { code = code, share = true }); | |||
| } | |||
| [HttpGet] | |||
| public async Task<IActionResult> Link(int id, bool? share) | |||
| public async Task<IActionResult> Link(Guid code, bool? share) | |||
| { | |||
| var model = await _modelFactory.PrepareLinkVM(id, share); | |||
| var model = await _modelFactory.PrepareLinkVM(code, share); | |||
| return View(model); | |||
| } | |||
| @@ -5,5 +5,5 @@ namespace SecureSharing.Infrastructure; | |||
| public interface IModelFactory | |||
| { | |||
| //public MessageModel PrepareMessageVM(MessageDto message); | |||
| public Task<LinkModel> PrepareLinkVM(int id, bool? share); | |||
| public Task<LinkModel> PrepareLinkVM(Guid code, bool? share); | |||
| } | |||
| @@ -12,17 +12,20 @@ public sealed class ModelFactory : IModelFactory | |||
| _messageService = messageService; | |||
| } | |||
| public async Task<LinkModel> PrepareLinkVM(int id, bool? share) | |||
| public async Task<LinkModel> PrepareLinkVM(Guid code, bool? share) | |||
| { | |||
| //share is true when the link is created | |||
| LinkModel model = null; | |||
| try | |||
| { | |||
| var message = await _messageService.GetById(id); | |||
| var message = await _messageService.GetByCode(code); | |||
| model = new LinkModel { MessageModel = new MessageModel { Id = id, Text = message.Text }, Share = share }; | |||
| model.IsValid = message.IsValid; | |||
| model = new LinkModel | |||
| { | |||
| MessageModel = new MessageModel { Code = code, Text = message.Text }, Share = share, | |||
| IsValid = message.IsValid | |||
| }; | |||
| if (model.IsValid) | |||
| { | |||
| @@ -38,7 +41,7 @@ public sealed class ModelFactory : IModelFactory | |||
| else | |||
| { | |||
| //ONE_TIME sharing: make the message invalid now so that it can't be accessed next time | |||
| if (share == null || share.Value == false) await _messageService.InvalidateMessage(message.Id); | |||
| if (share is null or false) await _messageService.InvalidateMessage(message.Id); | |||
| } | |||
| } | |||
| } | |||
| @@ -6,6 +6,7 @@ public sealed class MessageModel | |||
| { | |||
| public int Id { get; set; } | |||
| public string Text { get; set; } | |||
| public Guid Code { get; set; } | |||
| public PeriodOfValidity ChosenPeriod { get; set; } | |||
| // public Dictionary<int, string> AvailablePeriods { get; set; } | |||
| @@ -25,7 +25,7 @@ else | |||
| </div> | |||
| <div id="div-link" class="label-text link-show"> | |||
| @{ | |||
| var link = Url.Action("Link", "Home", new { id = Model.MessageModel.Id }, "https"); | |||
| var link = Url.Action("Link", "Home", new { code = Model.MessageModel.Code }, "https"); | |||
| } | |||
| <a id="a-link" href="@link">@link</a> | |||
| </div> | |||