public async Task <IActionResult> OnGet() { Item = await new Base().Get(SiteSettings, Admin, PageName); if (Item == null) { return(NotFound()); } RepositoryData = await Testimonial.Item(SiteSettings.Site, QueryId) ?? new DataModel { Id = QueryId, Name = string.Empty, EmailAddress = string.Empty, Work = await Work.Item(QueryId), Entries = new List <LocalizedDataModel>() }; if (RepositoryData.Work == null) { return(NotFound()); } // ReSharper disable once InvertIf if (!RepositoryData.Entries.Any()) { var testimonial = new LocalizedDataModel { Lcid = SiteSettings.Lcid, Html = string.Empty }; RepositoryData.Entries.Add(testimonial); } else { LocalizedDataModel entry = RepositoryData.Entries.FirstOrDefault(x => x.Lcid == SiteSettings.Lcid); if (entry == null) { return(NotFound()); } RepositoryData.Entries.Remove(entry); entry.Html = entry.Html.Replace("<p>", string.Empty).Replace("</p>", string.Empty); RepositoryData.Entries.Add(entry); } Session.Json.SetObject(HttpContext.Session, Session.Key.TestimonialDataModel, RepositoryData); Data = new EditModel { Cover = RepositoryData.Work.Cover.Path, Author = RepositoryData.Work.Authors, EmailAddress = RepositoryData.EmailAddress, Text = RepositoryData.Entries.FirstOrDefault(x => x.Lcid == SiteSettings.Lcid)?.Html, Title = RepositoryData.Work.Title }; return(Page()); }