public void DeleteEmployee(int id) { PRACOWNIK e = db.PRACOWNIK.Find(id); db.PRACOWNIK.Remove(e); }
public PRACOWNIK UpdateEmployee(PRACOWNIK e) { db.Entry(e).State = EntityState.Modified; return(e); }
public PRACOWNIK AddEmployee(PRACOWNIK e) { db.PRACOWNIK.Add(e); return(e); }
public PRACOWNIK UpdateEmployee(PRACOWNIK e) { db.Entry(e).State = EntityState.Modified; return e; }
public PRACOWNIK AddEmployee(PRACOWNIK e) { db.PRACOWNIK.Add(e); return e; }
public ActionResult EditEmployee(PRACOWNIK e) { int cinemaId = Int32.Parse(Request.Form["Cinema"]); int etId = Int32.Parse(Request.Form["EmployeeType"]); if(ModelState.IsValid) { e.FK_IdEtatu = etId; e.FK_IdKina = cinemaId; repository.UpdateEmployee(e); repository.Save(); return RedirectToAction("Employees"); } else { var etList = repository.GetEmployeeTypeIdsAndNames(); var cinList = repository.GetCinemaNamesAndIds(); List<SelectListItem> etypes = new List<SelectListItem>(); List<SelectListItem> cinemas = new List<SelectListItem>(); foreach (KeyValuePair<int, string> el in etList) { etypes.Add(new SelectListItem { Text = el.Value, Value = el.Key.ToString() }); } foreach (KeyValuePair<int, string> el in cinList) { cinemas.Add(new SelectListItem { Text = el.Value, Value = el.Key.ToString() }); } etypes.FirstOrDefault(el => Int32.Parse(el.Value) == etId).Selected = true; cinemas.FirstOrDefault(c => Int32.Parse(c.Value) == cinemaId).Selected = true; ViewBag.Cinema = cinemas; ViewBag.EmployeeType = etypes; return View(e); } }