/// <summary> /// Performs additional processing and loads related models. /// </summary> /// <param name="content">The source content</param> /// <param name="model">The target model</param> private Task ProcessAsync <T>(Data.Content content, T model) where T : Models.GenericContent { return(Task.Run(() => { // Map category if (content.Category != null && model is Models.ICategorizedContent categorizedModel) { categorizedModel.Category = new Models.Taxonomy { Id = content.Category.Id, Title = content.Category.Title, Slug = content.Category.Slug }; } // Map tags if (model is Models.ITaggedContent taggedContent) { foreach (var tag in content.Tags) { taggedContent.Tags.Add(new Models.Taxonomy { Id = tag.Taxonomy.Id, Title = tag.Taxonomy.Title, Slug = tag.Taxonomy.Slug }); } } // Map Blocks if (!(model is Models.IContentInfo) && model is Models.IBlockContent blockModel) { blockModel.Blocks = _service.TransformBlocks(content.Blocks.OrderBy(b => b.SortOrder), content.SelectedLanguageId); } })); }
public void OnPostSaveContent(string title, string body, string imgurl, bool isinmenu, bool ispublished, int menuorder, string contentid) { try { Data.Content dc = _context.Content.Where(x => x.Id == contentid).FirstOrDefault(); _context.Entry(dc).State = EntityState.Modified; // force ispublished = true; isinmenu = true; dc.Title = title; dc.Body = body; dc.ImageUrl = imgurl; dc.IsInMenu = isinmenu; dc.IsPublished = ispublished; dc.MenuOrder = menuorder; _context.Content.Update(dc); _context.SaveChanges(); ViewData["message"] = "Your content has been updated!"; } catch (Exception ex) { ViewData["message"] = $"Something went wrong. Error: {ex}"; } }
public void OnGet(string contentid) { _content = _context.Content.Where(x => x.Id == contentid).FirstOrDefault(); _context.Entry(_content).State = EntityState.Detached; if (_content is null) { ViewData["message"] = "Content was not found!"; } }
public IActionResult OnPostDeleteContent(string contentid) { Data.Content content = _context.Content.Where(x => x.Id == contentid).FirstOrDefault(); if (content is not null) { _context.Content.Remove(content); _context.SaveChanges(); } RefreshContent(); return(Page()); }
public void OnPostAddContent(string title, string body, string imgurl, bool isinmenu, bool ispublished, int menuorder) { try { Data.Content content = new Data.Content(title, body = body, isinmenu, ispublished, imgurl, menuorder); _context.Content.Add(content); _context.SaveChanges(); ViewData["message"] = "Your content has been added!"; } catch (Exception ex) { ViewData["message"] = $"Something went wrong. Error: {ex}"; } }
public override void Process() { Remoting.SaveContent rem; try { rem = new Remoting.SaveContent(_db, _version, _sendTimeout, _receiveTimeout, _sendBufferSize, _receiveBufferSize); } catch (Exception e) { Logger.Storage.Error("An exception occurred while instantiating the Transactions.Tasks.Remoting.SaveContent object.", e); throw; } rem.OnComplete += delegate(Remoting.Base sender, ICommandReply reply) { if (!((Commands.PutAttachmentReply)reply).Ok) { Version = null; Content = null; } else { Version = _version; Content = _version.Content; Version.UpdateRevision(((Commands.PutAttachmentReply)reply).Rev); } TriggerOnComplete(reply); }; rem.OnError += delegate(Remoting.Base sender, string message, Exception exception) { TriggerOnError(message, exception); }; rem.OnProgress += delegate(Remoting.Base sender, OpenDMS.Networking.Protocols.Tcp.DirectionType direction, int packetSize, decimal sendPercentComplete, decimal receivePercentComplete) { TriggerOnProgress(direction, packetSize, sendPercentComplete, receivePercentComplete); }; rem.OnTimeout += delegate(Remoting.Base sender) { TriggerOnTimeout(); }; rem.Process(); }
public void OnGet(string pageName) { if (pageName.ToLower().Equals("Contact".ToLower())) { showContactForm = true; } else { showContactForm = false; } if (pageName is not null) { // Get the current content named in "page string" from database using the title as a find atribute. Data.Content content = _context.Content.Where(page => page.Title.Equals(pageName)).FirstOrDefault(); if (content is not null) { if (content.IsPublished) { contentModel.Title = content.Title; contentModel.Body = content.Body; contentModel.ImageUrl = content.ImageUrl; } else { contentModel.Title = "Sorry, this page has not been published"; } } else { contentModel.Title = "Sorry, this page does not exist (404)"; } } else { contentModel.Title = "Sorry, you have no query"; } }