public ActionResult _Create(Article model) { if (!ModelState.IsValid) { this.AddToastMessage("", "Alanları kontrol Ediniz", Enum.ToastrType.Warning); ViewBag.ArticleTypeId = new SelectList(new ArticleRepository().Types(), "Id", "Title", model.ArticleTypeId); ViewBag.PageId = new SelectList(new PageRepository().GetAll(), "Id", "Title", model.PageId); return View(model); } model.AuthorId = new AuthenticatedAuthor().Id; var res = new ArticleRepository().Create(model); if (res == Enum.EntityResult.Failed) { this.AddToastMessage("", "Makale oluşturulurken hata", Enum.ToastrType.Error); ViewBag.ArticleTypeId = new SelectList(new ArticleRepository().Types(), "Id", "Title", model.ArticleTypeId); ViewBag.PageId = new SelectList(new PageRepository().GetAll(), "Id", "Title", model.PageId); return View(model); } this.AddToastMessage("", "Kayıt Başarılı", Enum.ToastrType.Success); return RedirectToAction("Index"); }
public ActionResult _Create(Article model, HttpPostedFileBase photo) { if (!ModelState.IsValid) { this.AddToastMessage("", "Alanları kontrol Ediniz", Enum.ToastrType.Warning); ViewBag.ArticleTypeId = new SelectList(new ArticleRepository().Types(), "Id", "Title", model.ArticleTypeId); ViewBag.PageId = new SelectList(new PageRepository().GetAll(), "Id", "Title", model.PageId); return View(model); } if (photo?.ContentLength > 0) { var photofile = FileSave(photo, "Media", Enum.FileType.Media); if (photofile != null) { var media = new Media { FileId = photofile.Id, Active = true, AuthorId = new AuthenticatedAuthor().Id, CreateDateTime = DateTime.Now, AltText = model.Title, Description = model.Title, Title = model.Title }; if (new MediaRepository().Create(media) == Enum.EntityResult.Success) { this.AddToastMessage("", "Logo yüklendi", Enum.ToastrType.Success); model.MediaId = media.Id; } else { FileDelete(photofile); this.AddToastMessage("", "Logo yüklenirken hata", Enum.ToastrType.Error); this.AddToastMessage("", "Sayfayı yenileyin ve tekrar deneyin."); } } else { this.AddToastMessage("", "Logo yüklenirken hata", Enum.ToastrType.Error); this.AddToastMessage("", "Sayfayı yenileyin ve tekrar deneyin."); } } model.Permalink = Helper.CharacterCorrection(model.Title); model.AuthorId = new AuthenticatedAuthor().Id; var res = new ArticleRepository().Create(model); if (res == Enum.EntityResult.Failed) { this.AddToastMessage("", "Makale oluşturulurken hata", Enum.ToastrType.Error); ViewBag.ArticleTypeId = new SelectList(new ArticleRepository().Types(), "Id", "Title", model.ArticleTypeId); ViewBag.PageId = new SelectList(new PageRepository().GetAll(), "Id", "Title", model.PageId); return View(model); } this.AddToastMessage("", "Kayıt Başarılı", Enum.ToastrType.Success); return RedirectToAction("Index"); }
public PartialViewResult _List(int? typeId) { var list = new ArticleRepository().GetAll(typeId); return PartialView(list); }
public PartialViewResult _Edit(int id) { var item = new ArticleRepository().FindbyId(id); ViewBag.PageId = new SelectList(new PageRepository().GetAll(), "Id", "Title"); ViewBag.ArticleTypeId = new SelectList(new ArticleRepository().Types(), "Id", "Title", item.ArticleTypeId); return PartialView("_Create", item); }
public bool _DeleteType(int id) { var res = new ArticleRepository().DisableType(id); if (res == Enum.EntityResult.Failed) { this.AddToastMessage("", "Makale tipi silinirken hata", Enum.ToastrType.Error); return false; } this.AddToastMessage("", "Makale tipi silindi", Enum.ToastrType.Success); return true; }
public ActionResult _Edit(Article modified) { if (!ModelState.IsValid) { this.AddToastMessage("", "Alanları kontrol Ediniz", Enum.ToastrType.Warning); return View("_Create", modified); } var res = new ArticleRepository().Update(modified); if (res == Enum.EntityResult.Failed) { this.AddToastMessage("", "Makale güncellenirken hata", Enum.ToastrType.Error); return View("_Create", modified); } this.AddToastMessage("", "Kayıt Başarılı", Enum.ToastrType.Success); return RedirectToAction("Index"); }