public ActionResult Create(Anime anime) { if (this.ModelState.IsValid) { db.Animes.Add(anime); db.SaveChanges(); return(Redirect("/")); } return(View(anime)); }
public ActionResult DeleteConfirm(int?id, Anime animeModel) { //TODO: Implement me ... if (id == null) { return(HttpNotFound()); } using (var database = new AnimeListDbContext()) { Anime animeToBeDeleted = database.Animes.Find(id); if (animeToBeDeleted == null) { RedirectToAction("Index"); } database.Animes.Remove(animeToBeDeleted); database.SaveChanges(); } // } return(RedirectToAction("Index")); //TODO: Implement me ... END }
public ActionResult Create(Anime anime) { using (var db = new AnimeListDbContext()) { db.Animes.Add(anime); db.SaveChanges(); return(Redirect("/")); } }
public ActionResult DeleteConfirm(int?id, Anime animeModel) { using (var db = new AnimeListDbContext()) { db.Animes.Attach(animeModel); db.Animes.Remove(animeModel); db.SaveChanges(); return(Redirect("/")); } }
public ActionResult Create(Anime anime) { if (ModelState.IsValid) { using (var database = new AnimeListDbContext()) { database.Animes.Add(anime); database.SaveChanges(); } } return(RedirectToAction("Index")); }
public ActionResult Create(Anime anime) { if (ModelState.IsValid) { using (AnimeListDbContext db = new AnimeListDbContext()) { db.Animes.Add(anime); db.SaveChanges(); return(Redirect("/")); } } return(View()); }
public ActionResult DeleteConfirm(int?id, Anime animeModel) { using (var db = new AnimeListDbContext()) { var anime = db.Animes.Find(id); if (anime == null) { return(RedirectToAction("Index")); } db.Animes.Remove(anime); db.SaveChanges(); return(RedirectToAction("Index")); } }
public ActionResult Create(Anime anime) { if (ModelState.IsValid) { using (var db = new AnimeListDbContext()) { db.Animes.Add(anime); db.SaveChanges(); return(Redirect("/")); } } return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); }
public ActionResult Create(Anime anime) { if (string.IsNullOrWhiteSpace(anime.Description) || string.IsNullOrWhiteSpace(anime.Name) || anime.Description == "...") { return(Redirect("create")); } using (var db = new AnimeListDbContext()) { db.Animes.Add(anime); db.SaveChanges(); return(RedirectToAction("Index")); } }
public ActionResult DeleteConfirm(int?id, Anime animeModel) { using (var db = new AnimeListDbContext()) { Anime animeFromDb = db.Animes.Find(id); if (animeFromDb == null) { return(HttpNotFound()); } db.Animes.Remove(animeFromDb); db.SaveChanges(); return(Redirect("/")); } }
public ActionResult Create(Anime anime) { if (anime == null) { return(RedirectToAction("Index")); } if (string.IsNullOrWhiteSpace(anime.Name) || string.IsNullOrWhiteSpace(anime.Description) || string.IsNullOrWhiteSpace(anime.Watched) || anime.Rating == null) { ViewBag.Rating = anime.Rating; ViewBag.Name = anime.Name; ViewBag.Description = anime.Description; ViewBag.Message = "Попълни полетата!"; return(View()); } using (var db = new AnimeListDbContext()) { db.Animes.Add(anime); db.SaveChanges(); return(RedirectToAction("Index")); } }
public ActionResult DeleteConfirm(int?id, Anime animeModel) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } using (var db = new AnimeListDbContext()) { var anime = db.Animes .Where(a => a.Id == id) .First(); if (anime == null) { return(HttpNotFound()); } db.Animes.Remove(anime); db.SaveChanges(); return(RedirectToAction("Index")); } }