public ActionResult Create(CustomerRateTypeVM item)
        {
            if (ModelState.IsValid)
            {
                CustomerRateType obj = new CustomerRateType();


                int max = (from c in db.CustomerRateTypes orderby c.CustomerRateTypeID descending select c.CustomerRateTypeID).FirstOrDefault();

                if (max == null)
                {
                    obj.CustomerRateTypeID = 1;
                    obj.CustomerRateType1  = item.CustomerRateType;
                    obj.ZoneCategoryID     = item.ZoneCategoryID;
                    obj.StatusDefault      = item.StatusDefault;
                }
                else
                {
                    obj.CustomerRateTypeID = max + 1;
                    obj.CustomerRateType1  = item.CustomerRateType;
                    obj.ZoneCategoryID     = item.ZoneCategoryID;
                    obj.StatusDefault      = item.StatusDefault;
                }
                db.CustomerRateTypes.Add(obj);
                db.SaveChanges();
                TempData["SuccessMsg"] = "You have successfully added Customer Rate Type.";
                return(RedirectToAction("Index"));
            }


            return(View());
        }
        public ActionResult DeleteConfirmed(int id)
        {
            CustomerRateType customerratetype = db.CustomerRateTypes.Find(id);

            db.CustomerRateTypes.Remove(customerratetype);
            db.SaveChanges();
            TempData["SuccessMsg"] = "You have successfully Deleted Customer Rate Type.";
            return(RedirectToAction("Index"));
        }
        public ActionResult Details(int id = 0)
        {
            CustomerRateType customerratetype = db.CustomerRateTypes.Find(id);

            if (customerratetype == null)
            {
                return(HttpNotFound());
            }
            return(View(customerratetype));
        }
        public ActionResult Edit(CustomerRateTypeVM item)
        {
            CustomerRateType obj = new CustomerRateType();

            obj.CustomerRateTypeID = item.CustomerRateTypeID;
            obj.CustomerRateType1  = item.CustomerRateType;
            obj.ZoneCategoryID     = item.ZoneCategoryID;
            obj.StatusDefault      = item.StatusDefault;
            if (ModelState.IsValid)
            {
                db.Entry(obj).State = EntityState.Modified;
                db.SaveChanges();
                TempData["SuccessMsg"] = "You have successfully Updated Customer Rate Type.";
                return(RedirectToAction("Index"));
            }

            return(View());
        }