public ActionResult Create(CourierStatusVM c) { if (ModelState.IsValid) { CourierStatu obj = new CourierStatu(); int max = (from d in db.CourierStatus orderby d.CourierStatusID descending select d.CourierStatusID).FirstOrDefault(); if (max == null) { obj.CourierStatusID = 1; obj.CourierStatus = c.CourierStatus; obj.StatusTypeID = c.StatusTypeID; string statustype = db.tblStatusTypes.Where(cc => cc.ID == c.StatusTypeID).FirstOrDefault().Name; obj.StatusType = statustype; } else { obj.CourierStatusID = max + 1; obj.CourierStatus = c.CourierStatus; obj.StatusTypeID = c.StatusTypeID; string statustype = db.tblStatusTypes.Where(cc => cc.ID == c.StatusTypeID).FirstOrDefault().Name; obj.StatusType = statustype; } db.CourierStatus.Add(obj); db.SaveChanges(); TempData["SuccessMsg"] = "You have successfully added Courier Status."; return(RedirectToAction("Index")); } return(View()); }
public ActionResult DeleteConfirmed(int id) { CourierStatu courierstatu = db.CourierStatus.Find(id); db.CourierStatus.Remove(courierstatu); db.SaveChanges(); TempData["SuccessMsg"] = "You have successfully Deleted Courier Status."; return(RedirectToAction("Index")); }
public ActionResult Details(int id = 0) { CourierStatu courierstatu = db.CourierStatus.Find(id); if (courierstatu == null) { return(HttpNotFound()); } return(View(courierstatu)); }
public ActionResult Edit(CourierStatusVM c) { CourierStatu obj = new CourierStatu(); obj.CourierStatusID = c.CourierStatusID; obj.CourierStatus = c.CourierStatus; obj.StatusCourier = c.StatusCourier; obj.StatusTypeID = c.StatusTypeID; string statustype = db.tblStatusTypes.Where(cc => cc.ID == c.StatusTypeID).FirstOrDefault().Name; obj.StatusType = statustype; if (ModelState.IsValid) { db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); TempData["SuccessMsg"] = "You have successfully Updated Courier Status."; return(RedirectToAction("Index")); } return(View()); }