public bool Delete(long id) { WorkLocationMaster workLocationMaster = db.WorkLocationMaster.Find(id); db.WorkLocationMaster.Remove(workLocationMaster); db.SaveChanges(); return(true); }
public ActionResult DeleteConfirmed(long id) { WorkLocationMaster workLocationMaster = db.WorkLocationMasters.Find(id); db.WorkLocationMasters.Remove(workLocationMaster); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: WorkLocationMaster/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WorkLocationMaster workLocationMaster = db.WorkLocationMaster.Find(id); if (workLocationMaster == null) { return(HttpNotFound()); } return(View(workLocationMaster)); }
public ActionResult Edit([Bind(Include = "WorkID,WorkLocationName,SAPCode")] WorkLocationMaster workLocationMaster) { if (ModelState.IsValid) { bool isValid = db.WorkLocationMaster.Any(x => (x.WorkID != workLocationMaster.WorkID) && (x.WorkLocationName == workLocationMaster.WorkLocationName)); if (!isValid) { db.Entry(workLocationMaster).State = EntityState.Modified; db.SaveChanges(); ViewBag.success = "Your Record Successfully Updated!"; return(View()); } else { ViewBag.error = "Work Location is Already exist!"; return(View()); } } return(View(workLocationMaster)); }
public ActionResult Create([Bind(Include = "WorkID,WorkLocationName,SAPCode")] WorkLocationMaster workLocationMaster) { if (ModelState.IsValid) { bool isValid = db.WorkLocationMaster.Any(x => x.WorkLocationName == workLocationMaster.WorkLocationName); if (!isValid) { db.WorkLocationMaster.Add(workLocationMaster); db.SaveChanges(); ViewBag.success = "Work Location is Successfully created!"; ModelState.Clear(); return(View()); } else { ViewBag.error = "Sorry! Work Location is already exist!"; return(View(workLocationMaster)); } } return(View(workLocationMaster)); }