public ActionResult Create()
        {
            UserViewModel userViewModel = new UserViewModel();
          //  ViewBag.gridfilters = gridfilters;
            // userViewModel.userTypeList = _userBusiness.GetUserType();
            //if (Filters.AuthenticationModel.GlobalUser.getGlobalUser().UserType != "Admin")
            //{
            //    userViewModel.RegionList = _regionBusiness.GetAllRegion().Select(x => new SelectListItem
            //    {
            //        Text = x.Name.ToString(),
            //        Value = x.RegionID.ToString()
            //    }).ToList();
            //}
            ////else
            //{
            //    var user = _userBusiness.GetUserById(Convert.ToInt32(GlobalUser.getGlobalUser().UserId));


          
            //}
            return View(userViewModel);
        }
        public ActionResult Create(UserViewModel userViewModel)
        {
          
            if (ModelState.IsValid)
            {
                
                Mapper.CreateMap<UserViewModel, User>();
                User user = Mapper.Map<UserViewModel, User>(userViewModel);

                var result = _userBusiness.ValidateUser(user, "I");
                if (!string.IsNullOrEmpty(result))
                {
                    ModelState.AddModelError("Alert", result);
                    return View(userViewModel);
                }

                else
                {
                    //int vid = 0;
                    bool isSuccess = _userBusiness.AddUpdateDeleteUser(user, "I");
                    if (isSuccess)
                    {
                            TempData["Success"] = "User Created Successfully!!";
                            TempData["isSuccess"] = "true";
                            return RedirectToAction("Index");
                        
                    }
                    else
                    {
                       
                            TempData["Success"] = "Failed to create User!!";
                            TempData["isSuccess"] = "false";
                        
                    }
                }
            }
            
            return View(userViewModel);
        }
        public ActionResult Edit(UserViewModel userViewModel)
        {
            //ViewBag.gridfilters = gridfilters;

          //  int id = Convert.ToInt32(Md5Decryption.Decrypt(Id));
           // userViewModel.UserId = id;
            if (ModelState.IsValid)
            {
                Mapper.CreateMap<UserViewModel, User>();
                User user = Mapper.Map<UserViewModel, User>(userViewModel);

                var result = _userBusiness.ValidateUser(user, "U");
                if (!string.IsNullOrEmpty(result))
                {
                    ModelState.AddModelError("Alert", result);
                    return View(userViewModel);
                }
                //int vid = _versionDataBusiness.GetUnpublishedVersion();
                //if (vid == 0)
                //{
                //    ModelState.AddModelError("Alert", "New unpublished version not detected. Can not proceed. Create new version with out publishing it and try again.");
                //    TempData["Success"] = "New unpublished version not detected. Can not proceed. Create new version with out publishing it and try again.";
                //    TempData["isSuccess"] = "false";
                //    return RedirectToAction("Index", new { gridfilters = gridfilters });
                //}
                //else
                //{
                    bool isSuccess = _userBusiness.AddUpdateDeleteUser(user, "U");
                    if (isSuccess)
                    {
                        TempData["Success"] = "User Updated Successfully!!";
                        TempData["isSuccess"] = "true";

                        return RedirectToAction("Index");
                    }
                    else
                    {
                        TempData["Success"] = "Failed to update user!!";
                        TempData["isSuccess"] = "false";
                    }
                //}
            }
            return View(userViewModel);
        }