public Enum.EntityResult Delete(Article delete) { try { _db.Articles.Remove(delete); _db.SaveChanges(); return Enum.EntityResult.Success; } catch (Exception e) { return Enum.EntityResult.Failed; } }
public Enum.EntityResult Create(Article article) { try { article.Active = true; _db.Articles.Add(article); _db.SaveChanges(); return Enum.EntityResult.Success; } catch (Exception e) { return Enum.EntityResult.Failed; } }
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 Enum.EntityResult Disable(Article disable) { disable.Active = false; return Update(disable); }
public Enum.EntityResult Update(Article modified) { try { _db.Entry(modified).State = EntityState.Modified; _db.SaveChanges(); return Enum.EntityResult.Success; } catch (Exception e) { return Enum.EntityResult.Failed; } }
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 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"); }