public async Task <ActionResult> Create()
        {
            var empModel = new EmployeeModel();

            empModel.DeginationList          = new SelectList(await CommonModel.GetDesignations(), "Value", "Text");
            empModel.DepartmentList          = new SelectList(await CommonModel.GetDepartments(), "Value", "Text");
            empModel.AddressTypelist         = new SelectList(await CommonModel.GetLookup("ADDRESS"), "Value", "Text");
            empModel.CountryList             = new SelectList(drop.BindCountry(), "Value", "Text");
            empModel.CityList                = new SelectList(Enumerable.Empty <SelectList>());
            empModel.LocationList            = new SelectList(Enumerable.Empty <SelectListItem>());
            empModel.StateList               = new SelectList(Enumerable.Empty <SelectList>());
            empModel.CenterList              = new SelectList(Enumerable.Empty <SelectList>());
            empModel.Vehicle.VehicleTypeList = new SelectList(await CommonModel.GetLookup("Vehicle"), "Value", "Text");
            empModel.EngineerTypeList        = new SelectList(await CommonModel.GetLookup("Engineer Type"), "Value", "Text");
            if (CurrentUser.UserTypeName.ToLower().Contains("provider"))
            {
                empModel.IsProvider = true;
                if (CurrentUser.UserRole.Contains("Service Provider SC Admin"))
                {
                    empModel.ProviderId = CurrentUser.RefKey;
                }
                else
                {
                    empModel.CenterList = new SelectList(await CommonModel.GetServiceCenters(CurrentUser.RefKey), "Name", "Text");
                }
            }
            else if (CurrentUser.UserTypeName.ToLower().Contains("center"))
            {
                empModel.RefKey       = CurrentUser.RefKey;
                empModel.IsCenter     = true;
                empModel.ProviderList = new SelectList(Enumerable.Empty <SelectList>());
            }
            else
            {
                empModel.ProviderList = new SelectList(await CommonModel.GetServiceProviders(CurrentUser.CompanyId), "Name", "Text");
            }
            return(View(empModel));
        }
        public async Task <ActionResult> Edit(Guid empId)
        {
            var empModel = await _employee.GetEmployeeById(empId);

            empModel.RefKey          = empModel.CenterId;
            empModel.DeginationList  = new SelectList(await CommonModel.GetDesignations(), "Value", "Text");
            empModel.DepartmentList  = new SelectList(await CommonModel.GetDepartments(), "Value", "Text");
            empModel.ProviderList    = new SelectList(await CommonModel.GetServiceProviders(CurrentUser.CompanyId), "Name", "Text");
            empModel.AddressTypelist = new SelectList(await CommonModel.GetLookup("ADDRESS"), "Value", "Text");
            empModel.CountryList     = new SelectList(drop.BindCountry(), "Value", "Text");
            //empModel.StateList = new SelectList(drop.BindState(empModel.CountryId), "Value", "Text");
            empModel.LocationList            = new SelectList(drop.BindLocationforEmp(empModel.LocationId), "Value", "Text");
            empModel.CenterList              = new SelectList(await CommonModel.GetServiceCenters(empModel.ProviderId), "Name", "Text");
            empModel.Vehicle.VehicleTypeList = new SelectList(await CommonModel.GetLookup("Vehicle"), "Value", "Text");
            empModel.EngineerTypeList        = new SelectList(await CommonModel.GetLookup("Engineer Type"), "Value", "Text");
            empModel.CurrentEmail            = empModel.ConEmailAddress;
            empModel.CurrentIsUser           = empModel.IsUser;
            if (CurrentUser.UserTypeName.ToLower().Contains("provider"))
            {
                empModel.IsProvider = true;
                if (!CurrentUser.UserRole.Contains("Service Provider SC Admin"))
                {
                    empModel.CenterList = new SelectList(await CommonModel.GetServiceCenters(CurrentUser.RefKey), "Name", "Text");
                }
            }
            else if (CurrentUser.UserTypeName.ToLower().Contains("center"))
            {
                empModel.ProviderList = new SelectList(Enumerable.Empty <SelectList>());
                empModel.IsCenter     = true;
            }
            else
            {
                empModel.ProviderList = new SelectList(await CommonModel.GetServiceProviders(CurrentUser.CompanyId), "Name", "Text");
            }

            return(View(empModel));
        }
        public async Task <ActionResult> Edit(EmployeeModel empModel)
        {
            empModel.UserId    = CurrentUser.UserId;
            empModel.CompanyId = CurrentUser.CompanyId;
            if (empModel.EMPPhoto1 != null && empModel.EMPPhoto != null)
            {
                if (System.IO.File.Exists(Server.MapPath(folderPath + "DP/" + empModel.ConAdhaarFileName)))
                {
                    System.IO.File.Delete(Server.MapPath(folderPath + "DP/" + empModel.ConAdhaarFileName));
                }
            }
            if (empModel.ConAdhaarNumberFilePath != null && empModel.ConAdhaarFileName != null)
            {
                if (System.IO.File.Exists(Server.MapPath(folderPath + "ADHRS/" + empModel.ConAdhaarFileName)))
                {
                    System.IO.File.Delete(Server.MapPath(folderPath + "ADHRS/" + empModel.ConAdhaarFileName));
                }
            }
            if (empModel.ConVoterIdFileName != null && empModel.ConVoterIdFilePath != null)
            {
                if (System.IO.File.Exists(Server.MapPath(folderPath + "VoterIds/" + empModel.ConVoterIdFileName)))
                {
                    System.IO.File.Delete(Server.MapPath(folderPath + "VoterIds/" + empModel.ConVoterIdFileName));
                }
            }
            if (empModel.ConPanFileName != null && empModel.ConPanNumberFilePath != null)
            {
                if (System.IO.File.Exists(Server.MapPath(folderPath + "PANCards/" + empModel.ConPanFileName)))
                {
                    System.IO.File.Delete(Server.MapPath(folderPath + "PANCards/" + empModel.ConPanFileName));
                }
            }

            if (empModel.EMPPhoto1 != null)
            {
                empModel.EMPPhoto = SaveImageFile(empModel.EMPPhoto1, "DP");
            }
            if (empModel.ConAdhaarNumberFilePath != null)
            {
                empModel.ConAdhaarFileName = SaveImageFile(empModel.ConAdhaarNumberFilePath, "ADHRS");
            }
            if (empModel.ConVoterIdFilePath != null)
            {
                empModel.ConVoterIdFileName = SaveImageFile(empModel.ConVoterIdFilePath, "VoterIds");
            }
            if (empModel.ConPanNumberFilePath != null)
            {
                empModel.ConPanFileName = SaveImageFile(empModel.ConPanNumberFilePath, "PANCards");
            }
            var pwd = "CA5680";

            if (empModel.IsUser)
            {
                empModel.Password = Encrypt_Decript_Code.encrypt_decrypt.Encrypt(pwd, true);
            }


            empModel.DeginationList  = new SelectList(await CommonModel.GetDesignations(), "Value", "Text");
            empModel.DepartmentList  = new SelectList(await CommonModel.GetDepartments(), "Value", "Text");
            empModel.ProviderList    = new SelectList(await CommonModel.GetServiceProviders(CurrentUser.CompanyId), "Name", "Text");
            empModel.AddressTypelist = new SelectList(await CommonModel.GetLookup("ADDRESS"), "Value", "Text");
            //empModel.CountryList = new SelectList(drop.BindCountry(), "Value", "Text");
            //empModel.StateList = new SelectList(drop.BindState(empModel.CountryId), "Value", "Text");
            //empModel.CityList = new SelectList(drop.BindLocation(empModel.StateId), "Value", "Text");
            empModel.CenterList = new SelectList(await CommonModel.GetServiceCenters(empModel.ProviderId), "Name", "Text");
            empModel.Vehicle.VehicleTypeList = new SelectList(await CommonModel.GetLookup("Vehicle"), "Value", "Text");
            empModel.EngineerTypeList        = new SelectList(await CommonModel.GetLookup("Engineer Type"), "Value", "Text");
            empModel.EventAction             = 'U';
            if (CurrentUser.UserTypeName.ToLower().Contains("provider"))
            {
                if (!CurrentUser.UserRole.Contains("Service Provider SC Admin"))
                {
                    empModel.CenterList = new SelectList(await CommonModel.GetServiceCenters(CurrentUser.RefKey), "Name", "Text");
                }
            }
            else if (CurrentUser.UserTypeName.ToLower().Contains("center"))
            {
                empModel.ProviderList = new SelectList(Enumerable.Empty <SelectList>());
            }
            else
            {
                empModel.ProviderList = new SelectList(await CommonModel.GetServiceProviders(CurrentUser.CompanyId), "Name", "Text");
            }
            var response = await _employee.AddUpdateDeleteEmployee(empModel);

            if (response.IsSuccess)
            {
                if (empModel.IsUser && empModel.CurrentIsUser)
                {
                    var Templates = await _templateRepo.GetTemplateByActionName("User Registration", CurrentUser.CompanyId);

                    CurrentUser.Email = empModel.ConEmailAddress;
                    var WildCards = CommonModel.GetWildCards(CurrentUser.CompanyId);
                    var U         = WildCards.Where(x => x.Text.ToUpper() == "NAME").FirstOrDefault();
                    U.Val = empModel.ConFirstName;
                    U     = WildCards.Where(x => x.Text.ToUpper() == "PASSWORD").FirstOrDefault();
                    U.Val = pwd;
                    U     = WildCards.Where(x => x.Text.ToUpper() == "USER NAME").FirstOrDefault();
                    U.Val = empModel.ConEmailAddress;
                    CurrentUser.Mobile = empModel.ConMobileNumber;
                    var c = WildCards.Where(x => x.Val != string.Empty).ToList();
                    if (Templates != null)
                    {
                        await _emailSmsServices.Send(Templates, c, CurrentUser);
                    }
                }
            }
            TempData["response"] = response;

            return(RedirectToAction("Index"));
        }