Ejemplo n.º 1
0
        public ActionResult RegisterEmployee(Employee model)
        {
            //var errors = ModelState.Values.SelectMany(v => v.Errors);
            if (ModelState.IsValid)
            {
                string currentUser         = HttpContext.User.Identity.Name;
                bool   userExist           = false;
                bool   saveEmployeeRestult = _accountService.CreateEmployee(model.FormSubmit.CompanyId,
                                                                            model.FormSubmit.DepratmentId, model.FormSubmit.UserRoll, model.FormSubmit.UserName, model.FormSubmit.Email,
                                                                            out userExist);
                if (userExist == true)
                {
                    ViewBag.Failuremessage = "User name or Email already exist please choose another!";
                }
                else
                {
                    if (saveEmployeeRestult == true)
                    {
                        ViewBag.SuccessMsg = "Employee register successfully";
                    }
                    else
                    {
                        ViewBag.Failuremessage = "Error while adding employee, Please try again";
                    }
                }
            }

            ViewBag.Company    = _accountService.GetAllCompany();
            ViewBag.Department = _accountService.GetAllDepartment();
            ViewBag.UserRoles  = _accountService.GetAllRoles();
            return(View());
        }