Ejemplo n.º 1
0
        public async Task <IActionResult> EditUserAsync(EditUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                var editUserServiceModel = employeeService.EditUser(model);

                if (!employeeDataService.Exists(model.ManagerNickname))
                {
                    ModelState.AddModelError("ManagerNickname", "Username is inavalid");

                    return(View(model));
                }
                else
                {
                    editUserServiceModel.ManagerId = employeeDataService.FindByNickname(model.ManagerNickname);
                }

                editUserServiceModel.EmployeeId = model.EmployeeId;

                await employeeDataService.EditUserDetailsAsync(editUserServiceModel);

                return(this.RedirectToAction("Index", "Home"));
            }
            return(View(model));
        }
Ejemplo n.º 2
0
        public IActionResult Create(CreateProjectViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (!employeeDataService.Exists(model.ProjectManagerNick))
                {
                    ModelState.AddModelError("ProjectManagerNick", "Project Manager Nick is not valid");

                    return(View(model));
                }

                var companyId = userManager.GetUserAsync(this.User).Result.CompanyId;


                var project = new ProjectServiceModel
                {
                    Name           = model.Name,
                    Description    = model.Description,
                    StartDate      = model.StartDate,
                    EndDate        = model.EndDate,
                    CompanyId      = companyId,
                    ProjectManager = employeeDataService.FindByNickname(model.ProjectManagerNick)
                };

                projectDataService.Create(project);

                return(RedirectToAction("AllProjects", "Project"));
            }

            return(View(model));
        }