public static void Delete(Cinema item) { try { var items = GetAll(); var itemToDelete = items.Where(p => p.Id == item.Id).FirstOrDefault(); items.Remove(itemToDelete); Add(items); } catch { } }
public ActionResult Manage(Cinema item, string[] amenities) { if (item.Id != Guid.Empty) { Helper.Cinemas.Update(item); } else { item.Id = Guid.NewGuid(); Helper.Cinemas.Add(item); } return RedirectToAction("Index"); }
public static void Add(Cinema item) { try { var items = GetAll(); if (items.Any(p => p.Id == item.Id || (p.Name == item.Name && p.Address == item.Address))) return; items.Add(item); Add(items); } catch { } }
public ActionResult Manage(Guid? id) { var item = new Cinema(); ViewBag.Mode = "Add New"; ViewBag.IsEditMode = false; if (id.HasValue && id.Value != Guid.Empty) { item = Helper.Cinemas.Get(id.Value); ViewBag.Mode = "Edit"; ViewBag.IsEditMode = true; } return View(item); }
public static void Update(Cinema item) { try { var items = GetAll(); var oldItem = items.Where(p => p.Id == item.Id).FirstOrDefault(); items.Remove(oldItem); items.Add(item); Add(items); } catch { } }