public IActionResult Join(JoinViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (!projectDataService.Exists(model.ProjectCode))
                {
                    ModelState.AddModelError("ProjectCode", "Project code is not valid");

                    return(View(model));
                }

                var employeeId = userManager.GetUserId(this.User);

                var serviceModel = new JoinServiceModel
                {
                    EmployeeId  = employeeId,
                    ProjectCode = model.ProjectCode
                };

                projectDataService.Join(serviceModel);

                return(View());
            }
            return(View(model));
        }
示例#2
0
 /// <summary>
 /// Joinig a project
 /// </summary>
 /// <param name="model">JoinServiceModel which is a DTO which contains the needed info for this operations</param>
 public void Join(JoinServiceModel model)
 {
     var employeeProject = new EmployeeProject
     {
         Employee = employeeDataService.FindById(model.EmployeeId).Result,
         Project  = FindByCode(model.ProjectCode)
     };
 }