public void CreateOrUpdate(ZarplataBindingModel model) { using (var context = new KursachDatabase()) { Zarplata element = model.Id.HasValue ? null : new Zarplata(); if (model.Id.HasValue) { element = context.Zarplatas.FirstOrDefault(rec => rec.Id == model.Id); if (element == null) { throw new Exception("Элемент не найден"); } } else { element = new Zarplata(); context.Zarplatas.Add(element); } element.UserId = model.UserId; element.Name = model.Name; element.Summa = model.Summa; element.data = model.data; context.SaveChanges(); } }
public ActionResult Create(Zarplata zarplatas) { //Добавляем игрока в таблицу db.Zarplatas.Add(zarplatas); db.SaveChanges(); // перенаправляем на главную страницу return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { Zarplata b = db.Zarplatas.Find(id); if (b == null) { return(HttpNotFound()); } return(View(b)); }
public ActionResult DeleteConfirmed(int id) { Zarplata b = db.Zarplatas.Find(id); if (b == null) { return(HttpNotFound()); } db.Zarplatas.Remove(b); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(int?id) { if (id == null) { return(HttpNotFound()); } Zarplata Proizvodstvo = db.Zarplatas.Find(id); if (Proizvodstvo != null) { SelectList sotrudniks = new SelectList(db.Sotrudniks, "sotr_ID", "FIO"); ViewBag.Sotrudniks = sotrudniks; return(View(Proizvodstvo)); } return(HttpNotFound()); }
public void Delete(ZarplataBindingModel model) { using (var context = new KursachDatabase()) { Zarplata element = context.Zarplatas.FirstOrDefault(rec => rec.Id == model.Id); if (element != null) { context.Zarplatas.Remove(element); context.SaveChanges(); } else { throw new Exception("Элемент не найден"); } } }
public ActionResult Edit(Zarplata Proizvodstvo) { db.Entry(Proizvodstvo).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }