public ActionResult AddEditState(int id = 0, int pid = 0)
        {
            CustomMethods.ValidateRoles("State");
            if (!Convert.ToBoolean(Session["IsAdd"]) && !Convert.ToBoolean(Session["IsEdit"]))
            {
                return(View("ErrorPage", "Error"));
            }
            StateModel StateModel = new StateModel();
            int        take       = 10;
            int        skip       = take * pid;

            StateModel.PageID  = pid;
            StateModel.Current = pid + 1;
            ViewBag.c          = StateModel.PageID;
            if (id != 0)
            {
                var objstate = new StateBLL {
                }.GetSubStateById(id);
                if (objstate != null)
                {
                    StateModel.StateId   = objstate.StateId;
                    StateModel.StateName = objstate.StateName;
                    StateModel.CountryId = objstate.CountryId;
                    StateModel.IsActive  = Convert.ToBoolean(objstate.IsActive);
                }
            }
            CustomMethods.BindCountryList(StateModel);
            return(View(StateModel));
        }
        public ActionResult AddEditCity(CityModel model)
        {
            int     result  = 0;
            CityBLL CityBLL = new CityBLL();

            try
            {
                if (model.CityId == 0)
                {
                    if (!Convert.ToBoolean(Session["Add"]))
                    {
                        return(View("ErrorPage"));
                    }
                }
                else
                {
                    if (!Convert.ToBoolean(Session["Edit"]))
                    {
                        return(View("ErrorPage"));
                    }
                }
                if (ModelState.IsValid)
                {
                    if (model.CityId == 0)
                    {
                        var checkDuplicate = objdb.Cities.Where(x => x.CityName == model.CityName).FirstOrDefault();
                        if (checkDuplicate == null)
                        {
                            int res = new CityBLL {
                            }.AddEditCity(new CityModel
                            {
                                CityName  = model.CityName,
                                StateId   = model.StateId,
                                IsActive  = model.IsActive,
                                CreatedBy = Convert.ToInt32(Session["UserId"]),
                            });
                            if (res != 0)
                            {
                                Session["Success"] = "Successfully Added The Record";
                                return(RedirectToAction("City"));
                            }
                        }
                        Session["Error"] = "Record Already Exists";
                        return(RedirectToAction("City"));
                    }


                    else
                    {
                        if (model.CityId == 0)
                        {
                            Session["Error"] = "Record Already Exists";
                            return(RedirectToAction("AddEditCity"));
                        }
                        else
                        {
                            model.UpdatedBy = Convert.ToInt32(Session["UserId"]);
                            result          = CityBLL.AddEditCity(model);

                            if (result != 0)
                            {
                                Session["Success"] = "Successfully Updated The Record";
                                return(RedirectToAction("City"));
                            }
                        }
                    }
                }
                CustomMethods.BindStateList(model);
                return(View(model));
            }
            catch (Exception)
            {
                Session["Error"] = "An Error has occured";
                CustomMethods.BindCountryList(model);
                return(View(model));

                throw;
            }
        }