public ActionResult Edit(NewsViewModel model) { if (Request.Cookies["MagazineId"].Value == null) { SetMessage("Lo sentimos, ha ocurrido un error. Inténtelo de nuevo.", BootstrapAlertTypes.Danger); return(RedirectToAction("Index", "Magazines")); } int magId = Int32.Parse(Request.Cookies["MagazineId"].Value); var user = UserService.GetCurrentUser(); var relation = UserService.UserInMagazine(magId, user.UserId); ViewBag.MagId = magId; if (!relation) { return(RedirectToAction("Index", "Magazines")); } ViewBag.CategoryId = new SelectList(MagazineService.GetCategoriesByMagazineId(magId), "CategoryId", "Name"); if (!ModelState.IsValid) { return(View(model)); } var category = MagazineService.GetCategoryById(model.CategoryId); if (category == null) { SetMessage("No se encontró la categoría.", BootstrapAlertTypes.Danger); return(RedirectToAction("MyNews")); } //} DateTime?parsedDate = DateTime.Now; try { parsedDate = DateTime.ParseExact(model.CreationDate, "dd/MM/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture); } catch (Exception ex) { parsedDate = null; } if (!MagazineService.EditNews(model.NewsId, model.Title, model.Description, model.MainImage, model.Thumbnail, model.Body, model.CategoryId, model.Permalink, model.MetaDesc, model.MetaTags, model.Alt, model.VideoEmbed, parsedDate)) { SetMessage(MagazineService.ServiceTempData); return(RedirectToAction("MyNews")); } SetMessage("Noticia editada exitosamente", BootstrapAlertTypes.Success); return(RedirectToAction("MyNews")); }