コード例 #1
0
        public ActionResult AddEmployee(EmployeeViewModel employeeViewModel)
        {
            Employee employee = new Employee();

            if (ModelState.IsValid)
            {
                bool existsResult = employeeBL.CheckExists(employeeViewModel.EmailId, employeeViewModel.Mobilenumber);
                if (existsResult == true)
                {
                    AccountDetails accountDetails = new AccountDetails();
                    accountDetails.Username = employeeViewModel.EmailId;
                    accountDetails.Password = employeeBL.GeneratePassword(employeeViewModel.EmailId, employeeViewModel.Mobilenumber.ToString());
                    accountDetails.Role     = "User";
                    AccountDetails account   = employeeBL.AddAccountDetails(accountDetails);
                    Employee       employees = AutoMapper.Mapper.Map <EmployeeViewModel, Employee>(employeeViewModel);
                    employees.AccountId = account.AccountId;
                    Employee employeeDetails = employeeBL.Add(employees);
                    return(RedirectToAction("DisplayEmployeeDetails"));
                }
                else
                {
                    Response.Write("Employee is alreay exists");
                }
            }
            ViewBag.Departments = new SelectList(departmentBL.GetDepartments(), "DepartmentID", "DepartmentName");
            ViewBag.Designation = new SelectList(designationBL.GetDesignations(), "DesignationID", "DesignationName");
            return(View());
        }
コード例 #2
0
 public void Add(Employee employee)
 {
     _employeeBL.Add(employee);
 }