public ActionResult Add(EditArticleViewModel vm) { try { this.articles.Insert( new { vm.Title, IntroText = vm.IntroText ?? string.Empty, Content = vm.Content ?? string.Empty, CreatedBy = this.CurrentUserID, ModifiedBy = this.CurrentUserID, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, vm.SectionID, vm.IsPublished }); } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); this.SetAlertMessage("Ocurrió un error al agregar el artículo.", AlertClass.AlertDanger); vm.Action = "Add"; vm.PageTitle = "Agregar artículo"; return this.View("Edit", vm); } return this.RedirectToAction("Index", new { id = vm.SectionID }); }
public ActionResult Add(string id) { var vm = new EditArticleViewModel { Action = "Add", PageTitle = "Agregar artículo", ArticleID = 0, IntroText = null, Content = null, IsPublished = true, SectionID = int.Parse(id) }; return this.View("Edit", vm); }
public ActionResult Edit(EditArticleViewModel vm) { try { this.articles.Update( new { vm.Title, IntroText = vm.IntroText ?? string.Empty, Content = vm.Content ?? string.Empty, ModifiedBy = this.CurrentUserID, UpdatedAt = DateTime.Now, vm.IsPublished }, vm.ArticleID); } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); this.SetAlertMessage("Ocurrió un error al guardar el artículo.", AlertClass.AlertDanger); return this.View(vm); } return this.RedirectToAction("Index", new { id = vm.SectionID }); }