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 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());
        }
        //
        // GET: /CustomerRateType/Edit/5

        public ActionResult Edit(int id)
        {
            CustomerRateTypeVM obj = new CustomerRateTypeVM();

            ViewBag.zone = db.ZoneCategories.ToList();

            var item = (from c in db.CustomerRateTypes where c.CustomerRateTypeID == id select c).FirstOrDefault();

            if (item == null)
            {
                return(HttpNotFound());
            }
            else
            {
                obj.CustomerRateTypeID = item.CustomerRateTypeID;
                obj.CustomerRateType   = item.CustomerRateType1;
                obj.ZoneCategoryID     = item.ZoneCategoryID.Value;
                obj.StatusDefault      = item.StatusDefault.Value;
            }

            return(View(obj));
        }