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 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());
        }
        public ActionResult Edit(int id)
        {
            CourierStatusVM obj = new CourierStatusVM();

            ViewBag.statustype = db.tblStatusTypes.ToList();


            var c = (from d in db.CourierStatus where d.CourierStatusID == id select d).FirstOrDefault();

            if (c == null)
            {
                return(HttpNotFound());
            }
            else
            {
                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;
            }
            return(View(obj));
        }