コード例 #1
0
        public void Search_ContextHasRecords()
        {
            //Arrange
            var employees = EmployeeSeed.Data();

            //Act
            var results = _manager.Add(employees);

            //Assert
            Assert.True(results.Succeeded);
        }
コード例 #2
0
        public ActionResult Create(EmployeeViewModel employeeVM)
        {
            try
            {
                Employee employee = new Employee();
                employee.Name          = employeeVM.Name;
                employee.ContactNo     = employeeVM.ContactNo;
                employee.Email         = employeeVM.Email;
                employee.Address1      = employeeVM.Address1;
                employee.Address2      = employeeVM.Address2;
                employee.LicenceNo     = employeeVM.LicenceNo;
                employee.IsDriver      = employeeVM.IsDriver;
                employee.DepartmentId  = employeeVM.DepartmentId;
                employee.DesignationId = employeeVM.DesignationId;
                employee.DivisionId    = employeeVM.DivisionId;
                employee.DistrictId    = employeeVM.DivisionId;
                employee.ThanaId       = employeeVM.ThanaId;

                bool isSaved = _employeeManager.Add(employee);
                if (isSaved)
                {
                    TempData["msg"] = "Employee Save Successfully";
                }
                return(RedirectToAction("Create"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #3
0
        public ActionResult AddEmployee(Employee employee)
        {
            var departmentList = new DepartmentListViewModel().GetDepartmentsListItems();

            ViewBag.departmentList = departmentList;
            var roleList = new EmployeeListViewModel().GetRoles();

            ViewBag.roleList = roleList;
            if (!ModelState.IsValid)
            {
                return(View("AddEmployee"));
            }
            if (Request.Files.Count > 0)
            {
                string fileName  = $"{Guid.NewGuid()}{Path.GetFileName(Request.Files[0].FileName)}";
                string extension = Path.GetExtension(Request.Files[0].FileName);
                string filePath  = "~/Images/" + fileName + extension;
                Request.Files[0].SaveAs(Server.MapPath(filePath));
                if (extension == "")
                {
                    employee.EmployeeImage = "~/Icons/no-image-icon-4.png";
                }
                else
                {
                    employee.EmployeeImage = filePath;
                }
            }
            _employeeManager.Add(employee);
            return(RedirectToAction("Index"));
        }
コード例 #4
0
        public ActionResult Added(DriverViewModel driverVm)
        {
            if (ModelState.IsValid)
            {
                Employee employee = new Employee();
                employee.Name          = driverVm.Name;
                employee.ContactNo     = driverVm.ContactNo;
                employee.Email         = driverVm.Email;
                employee.Address1      = driverVm.Address1;
                employee.Address2      = driverVm.Address2;
                employee.LicenceNo     = driverVm.LicenceNo;
                employee.IsDriver      = driverVm.IsDriver;
                employee.DepartmentId  = driverVm.DepartmentId;
                employee.DesignationId = driverVm.DesignationId;
                employee.DivisionId    = driverVm.DivisionId;
                employee.DistrictId    = driverVm.DistrictId;
                employee.ThanaId       = driverVm.ThanaId;

                bool isSaved = _employeeManager.Add(employee);
                if (isSaved)
                {
                    TempData["msg"] = "Driver Save Successfully.";
                    return(RedirectToAction("Index", "Driver"));
                }
                TempData["msg"] = "Driver Not Saved Successfully.";
                return(RedirectToAction("Added"));
            }
            return(View());
        }
コード例 #5
0
        public async Task <HttpResponseMessage> Post(EmployeeModel employeeToBeAdded)
        {
            if (employeeToBeAdded == null)
            {
                HttpResponseMessage badRequestResponse = Request.CreateResponse(HttpStatusCode.BadRequest);
                badRequestResponse.Content = new StringContent("Employee details not provided", Encoding.Unicode);

                //Return the error response.
                return(badRequestResponse);
            }
            else if (string.IsNullOrEmpty(employeeToBeAdded.GivenName))
            {
                HttpResponseMessage badRequestResponse = Request.CreateResponse(HttpStatusCode.BadRequest);
                badRequestResponse.Content = new StringContent("Employee Name can not be empty", Encoding.Unicode);

                //Return the error response.
                return(badRequestResponse);
            }
            if (employeeToBeAdded.DateOfBirth.Equals(DateTime.MinValue))
            {
                HttpResponseMessage badRequestResponse = Request.CreateResponse(HttpStatusCode.BadRequest);
                badRequestResponse.Content = new StringContent("Invalid Date of birth", Encoding.Unicode);

                //Return the error response.
                return(badRequestResponse);
            }
            try
            {
                var employee = await _iEmployeeManager.Get(employeeToBeAdded.Id);

                if (employee != null)
                {
                    HttpResponseMessage badRequestResponse = Request.CreateResponse(HttpStatusCode.BadRequest);
                    badRequestResponse.Content = new StringContent("An employee with Same ID already exists", Encoding.Unicode);

                    //Return the error response.
                    return(badRequestResponse);
                }
                var employeeEntity = new Employee
                {
                    Id          = employeeToBeAdded.Id,
                    GivenName   = employeeToBeAdded.GivenName,
                    SurName     = employeeToBeAdded.SurName,
                    DateOfBirth = employeeToBeAdded.DateOfBirth,
                    ManagerName = employeeToBeAdded.ManagerName
                };
                var employeeAdded = await _iEmployeeManager.Add(employeeEntity);

                HttpResponseMessage createdResponse = Request.CreateResponse(HttpStatusCode.Created);
                createdResponse.Content = new StringContent("Created Successfully", Encoding.Unicode);


                return(createdResponse);
            }
            catch
            {
                HttpResponseMessage internalServerErrorResponse = Request.CreateResponse(HttpStatusCode.InternalServerError, "Error occured while adding new employee");
                return(internalServerErrorResponse);
            }
        }
コード例 #6
0
        public ActionResult Create(EmployeeViewModel employeeViewModel)
        {
            string userId   = User.Identity.GetUserId();
            var    userName = User.Identity.Name;

            string fileName  = Path.GetFileNameWithoutExtension(employeeViewModel.Image.FileName);
            string extension = Path.GetExtension(employeeViewModel.Image.FileName);
            var    fileNames = fileName + DateTime.Now.ToString("yy-mm-dd") + extension;

            string path = fileName + DateTime.Now.ToString("yy-mm-dd") + extension;

            fileName = Path.Combine(Server.MapPath("~/EmployeeImage/"), fileNames);
            employeeViewModel.Image.SaveAs(fileName);


            Employee employee = new Employee();

            employee.Name      = employeeViewModel.Name;
            employee.Email     = employeeViewModel.Email;
            employee.ContactNo = employeeViewModel.ContactNo;
            employee.Address   = employeeViewModel.Address;
            employee.Gender    = employeeViewModel.Gender;
            employee.UserId    = Convert.ToInt32(userId);
            employee.UserName  = userName;
            employee.FilePath  = path;

            bool isSaved = employeeManager.Add(employee);

            if (isSaved)
            {
                AppUserManager.AddEmployeeToUser(employee);
                return(RedirectToAction("Index"));
            }
            return(View());
        }
コード例 #7
0
        public ActionResult Create(EmployeeViewModel employeeVM)
        {
            if (ModelState.IsValid)
            {
                Employee employee = new Employee
                {
                    //UserId = user.Id,
                    Name      = employeeVM.Name,
                    ContactNo = employeeVM.ContactNo,
                    Email     = employeeVM.Email,
                    Address1  = employeeVM.Address1,
                    Address2  = employeeVM.Address2,
                    Status    = "employee",
                    //IsDriver = employeeVM.IsDriver,
                    DepartmentId  = employeeVM.DepartmentId,
                    DesignationId = employeeVM.DesignationId,
                    DivisionId    = employeeVM.DivisionId,
                    DistrictId    = employeeVM.DivisionId,
                    ThanaId       = employeeVM.ThanaId
                };

                bool isSaved = _employeeManager.Add(employee);
                if (isSaved)
                {
                    TempData["msg"] = "Employee Save Successfully!";
                    return(RedirectToAction("Index"));
                }

                TempData["msg"] = "Employee Not Saved!";
                return(RedirectToAction("Create"));
            }
            return(View());
        }
コード例 #8
0
        public void AddNullEmployee()
        {
            _manager = new EmploeeManager("testfile.json");
            int before = _manager.GetAll().Count;

            _manager.Add(null);
            int after = _manager.GetAll().Count;

            Assert.AreNotEqual <int>(before, after);
        }
コード例 #9
0
        public void UseEmptyFileName()
        {
            _manager = new EmploeeManager("");
            int before = _manager.GetAll().Count;

            _manager.Add(null);
            int after = _manager.GetAll().Count;

            Assert.AreNotEqual <int>(before, after);
        }
コード例 #10
0
        public ActionResult AddEmployee(Employee anEmployee, HttpPostedFileBase EmployeeImage, HttpPostedFileBase EmployeeSignature)
        {
            try
            {
                var user = (ViewUser)Session["user"];
                anEmployee.UserId = user.UserId;
                if (EmployeeImage != null)
                {
                    string ext   = Path.GetExtension(EmployeeImage.FileName);
                    string image = Guid.NewGuid().ToString().Replace("-", "").ToLower().Substring(2, 10) + ext;
                    string path  = Path.Combine(
                        Server.MapPath("~/Images/Employees"), image);
                    // file is uploaded
                    EmployeeImage.SaveAs(path);
                    anEmployee.EmployeeImage = "Images/Employees/" + image;
                }
                if (EmployeeSignature != null)
                {
                    string ext  = Path.GetExtension(EmployeeSignature.FileName);
                    string sign = Guid.NewGuid().ToString().Replace("-", "").ToLower().Substring(2, 10) + ext;
                    string path = Path.Combine(
                        Server.MapPath("~/Images/Signatures"), sign);
                    // file is uploaded
                    EmployeeSignature.SaveAs(path);
                    anEmployee.EmployeeSignature = "Images/Signatures/" + sign;
                }

                var result = _iEmployeeManager.Add(anEmployee);
                if (result)
                {
                    TempData["Message"] = "Saved Successfully!";
                }
                else
                {
                    TempData["Message"] = "Failed to Save";
                }



                ViewBag.EmployeeTypeId = new SelectList(_iEmployeeTypeManager.GetAll(), "EmployeeTypeId", "EmployeeTypeName");
                ViewBag.BranchId       = new SelectList(_iBranchManager.GetAllBranches(), "BranchId", "BranchName");
                ViewBag.DepartmentId   = new SelectList(_iDepartmentManager.GetAll(), "DepartmentId", "DepartmentName");
                ViewBag.DesignationId  = new SelectList(_iDesignationManager.GetAll(), "DesignationId", "DesignationName");
                return(View());
            }
            catch (Exception e)
            {
                Log.WriteErrorLog(e);
                ViewBag.EmployeeTypeId = new SelectList(_iEmployeeTypeManager.GetAll(), "EmployeeTypeId", "EmployeeTypeName");
                ViewBag.BranchId       = new SelectList(_iBranchManager.GetAllBranches(), "BranchId", "BranchName");
                ViewBag.DepartmentId   = new SelectList(_iDepartmentManager.GetAll(), "DepartmentId", "DepartmentName");
                ViewBag.DesignationId  = new SelectList(_iDesignationManager.GetAll(), "DesignationId", "DesignationName");
                return(View());
            }
        }
コード例 #11
0
        // [ValidateAntiForgeryToken]
        public ActionResult Create(Employee employee)
        {
            if (ModelState.IsValid)
            {
                _iEmployeeManager.Add(employee);

                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
コード例 #12
0
 public ActionResult Create(Employee employee)
 {
     try
     {
         employeeManager.Add(employee);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
コード例 #13
0
        public void AddEmployee()
        {
            _manager = new EmploeeManager("testfile.json");
            int before = _manager.GetAll().Count;

            _manager.Add(new Employee()
            {
                FirstName = "James", LastName = "Doe", SalaryPerHour = 120
            });
            int after = _manager.GetAll().Count;

            Assert.AreNotEqual <int>(before, after);
        }
コード例 #14
0
        public IActionResult Add([FromBody] EmployeeCreateModel employee)
        {
            Request.Headers.TryGetValue("Authorization", out var token);
            string email = _accountManager.GetEmailByToken(token);

            try
            {
                _employeeManager.Add(employee, email);
                return(Ok("Success!!!"));
            }
            catch (Exception e)
            {
                return(Conflict(e.Message));
            }
        }
コード例 #15
0
        //[System.Web.Http.Route("Emp/AddEmp/")]
        //[System.Web.Http.HttpPost]
        public JsonResult AddEmp(Employee emp)
        {
            string cr = string.Empty;

            try
            {
                _iEmployeeManager.Add(emp);
                cr = "Inserted";
                //   cr.httpStatusCode = res ? HttpStatusCode.OK : HttpStatusCode.BadRequest;
            }
            catch (Exception ex)
            {
                cr = "Failed";
            }
            return(Json(cr, JsonRequestBehavior.AllowGet));
        }
コード例 #16
0
        public ActionResult Create([Bind(Include = "EmployeeID,DepartmentID,EmployeeName,DesignationID,ContactNo,Email")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                //db.Employees.Add(employee);
                //db.SaveChanges();
                _employeeManager.Add(employee);
                return(RedirectToAction("Index"));
            }

            var DepartmentsList  = _departmentManager.GetAll();
            var DesignationsList = _designationManager.GetAll();

            ViewBag.DepartmentID  = new SelectList(DepartmentsList, "DepartmentID", "DepartmentName");
            ViewBag.DesignationID = new SelectList(DesignationsList, "DesignationID", "DesignationName");
            return(View(employee));
        }
コード例 #17
0
        public ActionResult Create([Bind(Include = "Id,Name,EmployeeDesignationId,DepartmentId,ContactNo,Address")] EmployeeViewModel employeeVm)
        {
            if (ModelState.IsValid)
            {
                Employee employee = Mapper.Map <Employee>(employeeVm);
                _employeeManager.Add(employee);

                TempData["Message"] = "Employee save successfully!";
                return(RedirectToAction("Index"));
            }

            ViewBag.DepartmentId          = new SelectList(_departmentManager.GetAll(), "Id", "Name");
            ViewBag.EmployeeDesignationId = new SelectList(new[] { new SelectListItem()
                                                                   {
                                                                       Value = "", Text = "Select Designation"
                                                                   } }, "Value", "Text");
            return(View(employeeVm));
        }
コード例 #18
0
        public async Task <IActionResult> Create(EmployeeCreateViewModel model, IFormFile Image)
        {
            if (ModelState.IsValid)
            {
                Employee employee = _maper.Map <Employee>(model);
                if (Image.Length > 0)
                {
                    using (MemoryStream stream = new MemoryStream())
                    {
                        await Image.CopyToAsync(stream);

                        employee.Image = stream.ToArray();
                    }
                }
                bool isvalid = _employeeManagerl.Add(employee);
                return(RedirectToAction("List"));
            }
            return(View());
        }
コード例 #19
0
 public IActionResult Add([FromBody] UserEmployeeDTO employeeDTO)
 {
     try
     {
         employeeDTO.UserId = _accountManager.Register(new RegisterDTO
         {
             Email    = employeeDTO.Email,
             Username = employeeDTO.Username,
             Password = employeeDTO.Password,
             Role     = employeeDTO.Role
         });
         _employeeManager.Add(employeeDTO);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
コード例 #20
0
ファイル: EmployeeController.cs プロジェクト: Javen17/Chinook
        public virtual async Task <IActionResult> Store(IFormCollection form)
        {
            var employee = new Employee();

            employee.Name        = form["Name"].ToString();
            employee.LastName    = form["LastName"].ToString();
            employee.Email       = form["Email"].ToString();
            employee.Phone       = form["Phone"].ToString();
            employee.JobPosition = form["JobPosition"].ToString();

            Console.WriteLine("DirectBoss: " + form["DirectBoss"].ToString());

            if (form["DirectBoss"].ToString() != "")
            {
                employee.DirectBossEmployeeId = long.Parse(form["DirectBoss"].ToString());
            }

            await _employeeManager.Add(employee);

            return(Redirect("/Employee"));
        }
コード例 #21
0
        public IActionResult AddEmployee([FromBody] EmployeeCreateDTO employee)
        {
            if (ModelState.IsValid)
            {
                var  employeeEntity = _mapper.Map <Employee>(employee);
                bool isSaved        = _employeeManager.Add(employeeEntity);

                if (isSaved)
                {
                    employeeEntity.Id = employee.Id;
                    return(Ok(employeeEntity));
                }
                else
                {
                    return(BadRequest("customer is invalid"));
                }
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }
        public ActionResult Create(EmployeeViewModel model)
        {
            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    string uniquefileName = null;
                    if (model.Photo != null)
                    {
                        string uploadsfolder = Path.Combine(_hostingEnvironment.WebRootPath, "Images");
                        uniquefileName = Guid.NewGuid().ToString() + "_" + model.Photo.FileName;
                        string filePath = Path.Combine(uploadsfolder, uniquefileName);
                        model.Photo.CopyTo(new FileStream(filePath, FileMode.Create));
                    }
                    //var employee = new Employee();
                    //employee.Name = model.Name;
                    //employee.DepartmentId = model.DepartmentId;

                    //employee.Email = model.Email;
                    //employee.Salary = model.Salary;
                    var employee = _mapper.Map <Employee>(model);
                    employee.PhotoPath = uniquefileName;

                    var isSeccess = _employeeManager.Add(employee);
                    if (isSeccess)
                    {
                        return(RedirectToAction(nameof(Index)));
                    }
                }

                return(NotFound());
            }
            catch
            {
                return(View());
            }
        }
コード例 #23
0
        public ActionResult Create([Bind(Include = "Id,FullName,Email,ContactNo,NID,BloodGroup,OrganizationId,DepartmentId,DesignationId,DrivingLicence,EmployeeTypeId,Addresses")] EmployeeViewModel employeeViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Employee employee = Mapper.Map <Employee>(employeeViewModel);

                    var email     = employee.Email.Trim();
                    var contactNo = employee.ContactNo.Trim();
                    var nid       = employee.NID.Trim();

                    if (_employeeManager.GetAll().Count(o => o.Email == email) > 0)
                    {
                        ViewBag.Message1 = "Employee email already exist.";
                    }

                    if (_employeeManager.GetAll().Count(o => o.ContactNo == contactNo) > 0)
                    {
                        ViewBag.Message2 = "Employee contact no already exist.";
                    }

                    if (_employeeManager.GetAll().Count(o => o.NID == nid) > 0)
                    {
                        ViewBag.Message3 = "Employee NID already exist.";
                    }
                    if (employee.DrivingLicence != null)
                    {
                        var drivingLicence = employee.DrivingLicence.Trim();
                        if (_employeeManager.GetAll().Count(o => o.DrivingLicence == drivingLicence) > 0)
                        {
                            ViewBag.Message4 = "Employee driving licence no already exist.";
                        }
                    }

                    if (ViewBag.Message1 == null && ViewBag.Message2 == null && ViewBag.Message3 == null && ViewBag.Message4 == null)
                    {
                        _employeeManager.Add(employee);
                        TempData["msg"] = "Information has been saved successfully";
                        return(RedirectToAction("Index"));
                    }
                }

                TempData["msg"]                = "Please Check Your Information! You have missed to give some information.";
                ViewBag.DepartmentId           = new SelectList(_departmentManager.GetAll(), "Id", "Name", employeeViewModel.DepartmentId);
                ViewBag.DesignationId          = new SelectList(_designationManager.GetAll(), "Id", "Title", employeeViewModel.DesignationId);
                ViewBag.OrganizationId         = new SelectList(_organizationManager.GetAll(), "Id", "Name", employeeViewModel.OrganizationId);
                ViewBag.EmployeeTypeId         = new SelectList(_employeeTypeManager.GetAll(), "Id", "Type", employeeViewModel.EmployeeTypeId);
                employeeViewModel.DivisionList = (List <Division>)_divisionManager.GetAllDivisions();
                ViewBag.DistrictDropDown       = new SelectList(new[] { new SelectListItem()
                                                                        {
                                                                            Value = "", Text = "Select District"
                                                                        } }, "Value", "Text");
                ViewBag.UpazilaDropDown = new SelectList(new[] { new SelectListItem()
                                                                 {
                                                                     Value = "", Text = "Select Upazila"
                                                                 } }, "Value", "Text");
                return(View(employeeViewModel));
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Employees", "Create")));
            }
        }
コード例 #24
0
        public ActionResult Create([Bind(Include = "Id,FullName,Email,ContactNo,NID,OrganizationId,DepartmentId,DesignationId,EmployeeTypeId,EmployeeImageId,Addresses,Password,ConfirmPassword,IsChecked")] EmployeeViewModel employeeViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (employeeViewModel.EmployeeTypeId == 1 && employeeViewModel.IsChecked == false)
                    {
                        Employee employee = Mapper.Map <Employee>(employeeViewModel);

                        var email     = employee.Email.Trim();
                        var contactNo = employee.ContactNo.Trim();
                        var nid       = employee.NID.Trim();

                        if (_employeeManager.GetAll().Count(o => o.Email == email) > 0)
                        {
                            ViewBag.Message1 = "Employee email already exist.";
                        }

                        if (_employeeManager.GetAll().Count(o => o.ContactNo == contactNo) > 0)
                        {
                            ViewBag.Message2 = "Employee contact no already exist.";
                        }

                        if (_employeeManager.GetAll().Count(o => o.NID == nid) > 0)
                        {
                            ViewBag.Message3 = "Employee NID already exist.";
                        }
                        if (employee.DrivingLicence != null)
                        {
                            var drivingLicence = employee.DrivingLicence.Trim();
                            if (_employeeManager.GetAll().Count(o => o.DrivingLicence == drivingLicence) > 0)
                            {
                                ViewBag.Message4 = "Employee driving licence no already exist.";
                            }
                        }

                        if (ViewBag.Message1 == null && ViewBag.Message2 == null && ViewBag.Message3 == null &&
                            ViewBag.Message4 == null)
                        {
                            var result = UserManager.AddUserForEmployee(employee);
                            if (result != 0)
                            {
                                employee.AppUserId = result;
                                bool save = _employeeManager.Add(employee);
                                if (save == true)
                                {
                                    try
                                    {
                                        SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
                                        smtpClient.Credentials = new NetworkCredential("*****@*****.**", "~Aa123456");
                                        smtpClient.EnableSsl   = true;


                                        MailMessage mailMessage = new MailMessage();
                                        mailMessage.From = new MailAddress("*****@*****.**");
                                        mailMessage.To.Add(new MailAddress(email));
                                        mailMessage.Subject = "Requisition Management System User Information";
                                        mailMessage.Body    = "Your Email Is: " + employee.Email + " " + "Your Password Is: " + employee.Password + " Login and update your password for your security Thanks";
                                        smtpClient.Send(mailMessage);

                                        TempData["msg"] = "Information has been saved and Send Email successfully";
                                        return(RedirectToAction("GetAllEmployee"));
                                    }
                                    catch (Exception ex)
                                    {
                                        return(View("Error", new HandleErrorInfo(ex, "Employees", "Create")));
                                    }
                                }
                            }
                        }
                    }
                    if (employeeViewModel.EmployeeTypeId == 1 && employeeViewModel.IsChecked == true)
                    {
                        Employee employee = Mapper.Map <Employee>(employeeViewModel);

                        var email     = employee.Email.Trim();
                        var contactNo = employee.ContactNo.Trim();
                        var nid       = employee.NID.Trim();

                        if (_employeeManager.GetAll().Count(o => o.Email == email) > 0)
                        {
                            ViewBag.Message1 = "Employee email already exist.";
                        }

                        if (_employeeManager.GetAll().Count(o => o.ContactNo == contactNo) > 0)
                        {
                            ViewBag.Message2 = "Employee contact no already exist.";
                        }

                        if (_employeeManager.GetAll().Count(o => o.NID == nid) > 0)
                        {
                            ViewBag.Message3 = "Employee NID already exist.";
                        }
                        if (employee.DrivingLicence != null)
                        {
                            var drivingLicence = employee.DrivingLicence.Trim();
                            if (_employeeManager.GetAll().Count(o => o.DrivingLicence == drivingLicence) > 0)
                            {
                                ViewBag.Message4 = "Employee driving licence no already exist.";
                            }
                        }

                        if (ViewBag.Message1 == null && ViewBag.Message2 == null && ViewBag.Message3 == null &&
                            ViewBag.Message4 == null)
                        {
                            var result = UserManager.AddControllerForEmployee(employee);
                            if (result != 0)
                            {
                                employee.AppUserId = result;
                                bool save = _employeeManager.Add(employee);
                                if (save == true)
                                {
                                    try
                                    {
                                        SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
                                        smtpClient.Credentials = new NetworkCredential("*****@*****.**", "~Aa123456");
                                        smtpClient.EnableSsl   = true;


                                        MailMessage mailMessage = new MailMessage();
                                        mailMessage.From = new MailAddress("*****@*****.**");
                                        mailMessage.To.Add(new MailAddress(email));
                                        mailMessage.Subject = "Requisition Management System User Information";
                                        mailMessage.Body    = "Your Email Is: " + employee.Email + " " + "Your Password Is: " + employee.Password;
                                        smtpClient.Send(mailMessage);

                                        TempData["msg"] = "Information has been saved and Send Email successfully";
                                        return(RedirectToAction("GetAllEmployee"));
                                    }
                                    catch (Exception ex)
                                    {
                                        return(View("Error", new HandleErrorInfo(ex, "Employees", "Create")));
                                    }
                                }
                            }
                        }
                    }
                }

                TempData["msg"]                = "Please Check Your Information! You have missed to give some information.";
                ViewBag.DepartmentId           = new SelectList(_departmentManager.GetAll(), "Id", "Name", employeeViewModel.DepartmentId);
                ViewBag.DesignationId          = new SelectList(_designationManager.GetAll(), "Id", "Title", employeeViewModel.DesignationId);
                ViewBag.OrganizationId         = new SelectList(_organizationManager.GetAll(), "Id", "Name", employeeViewModel.OrganizationId);
                ViewBag.EmployeeTypeId         = new SelectList(_employeeTypeManager.GetAll(), "Id", "Type", employeeViewModel.EmployeeTypeId);
                employeeViewModel.DivisionList = (List <Division>)_divisionManager.GetAllDivisions();
                ViewBag.DistrictDropDown       = new SelectList(new[] { new SelectListItem()
                                                                        {
                                                                            Value = "", Text = "Select District"
                                                                        } }, "Value", "Text");
                ViewBag.UpazilaDropDown = new SelectList(new[] { new SelectListItem()
                                                                 {
                                                                     Value = "", Text = "Select Upazila"
                                                                 } }, "Value", "Text");
                return(View(employeeViewModel));
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Employees", "Create")));
            }
        }