public void DeleteById(int id) // Delete function { Subsidary emp = GetById(id); dbconn.Subsidaries.Remove(emp); dbconn.SaveChanges(); }
public static SubsModel Translate(Subsidary sub) { var subModel = new SubsModel(); subModel.Name = sub.Name; subModel.ID = sub.ID; return(subModel); }
public Subsidary Add(Subsidary emp) // Adding Function { Subsidary addedEmp = dbconn.Subsidaries.Add(emp); dbconn.SaveChanges(); return(addedEmp); }
public ActionResult Edit([Bind(Include = "ID,Name")] Subsidary subsidary) { if (ModelState.IsValid) { subsidariesBusinessManager.Update(subsidary); } return(View(subsidary)); }
public ActionResult Create([Bind(Include = "ID,Name")] Subsidary subsidary) { if (ModelState.IsValid) { subsidariesBusinessManager.Add(subsidary); return(RedirectToAction("Index")); } return(View(subsidary)); }
// add subs public ActionResult AddSubs(int subId, string subname) { var sub = new Subsidary(); sub.Name = subname; sub.ID = subId; if (searchSubs.Where(n => n.ID == subId).FirstOrDefault() == null) { searchSubs.Add(sub); // adding } return(PartialView("_SubsFilter", searchSubs)); }
// GET: Subsidaries/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Subsidary subsidary = subsidariesBusinessManager.GetById(id.Value); if (subsidary == null) { return(HttpNotFound()); } return(View(subsidary)); }
// Adding a new Subsidary not in the database public ActionResult AddNewSubsidary(int empId, string subname) { var empSub = new EmpSubsidary(); Subsidary NewSubsidary = new Subsidary(); NewSubsidary.Name = subname; var added = subsidiariesbusinessManager.Add(NewSubsidary); empSub.EmpID = empId; List <Subsidary> sub = subsidiariesbusinessManager.GetUnmappedSubsidiariesByEmpID(empId); if (sub.Where(j => j.ID == added.ID).FirstOrDefault() != null) { empSub.SubsidaryID = added.ID; empSubsBusinessManager.Add(empSub); } var empSubs = empSubsBusinessManager.GetByEmployeeID(empId); return(PartialView("_UserSubs", empSubs)); }
public Subsidary Update(Subsidary emp) // Update Function { dbconn.Entry(emp).State = EntityState.Modified; dbconn.SaveChanges(); return(emp); }
public Subsidary GetById(int id) // Get the ID Function { Subsidary emp = dbconn.Subsidaries.Where(e => e.ID == id).FirstOrDefault(); return(emp); }
public Subsidary Update(Subsidary sub) { return(subsidariesDataManager.Update(sub)); }
public Subsidary Add(Subsidary sub) { return(subsidariesDataManager.Add(sub)); }