示例#1
0
        public void DeleteEmployee(int id)
        {
            PRACOWNIK e = db.PRACOWNIK.Find(id);

            db.PRACOWNIK.Remove(e);
        }
示例#2
0
 public PRACOWNIK UpdateEmployee(PRACOWNIK e)
 {
     db.Entry(e).State = EntityState.Modified;
     return(e);
 }
示例#3
0
 public PRACOWNIK AddEmployee(PRACOWNIK e)
 {
     db.PRACOWNIK.Add(e);
     return(e);
 }
示例#4
0
 public PRACOWNIK UpdateEmployee(PRACOWNIK e)
 {
     db.Entry(e).State = EntityState.Modified;
     return e;
 }
示例#5
0
 public PRACOWNIK AddEmployee(PRACOWNIK e)
 {
     db.PRACOWNIK.Add(e);
     return e;
 }
示例#6
0
 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);
     }
 }