/// <summary> /// Adds job title to an employee /// </summary> /// <param name="name">Job title name</param> /// <param name="user">user</param> public void AddJobTitle(string name, ClaimsPrincipal user) { if (!jobTitleDataService.Exists(name)) { jobTitleDataService.CreateJobTitile(name.ToString()); var companyId = jobTitleDataService.FindByName(name).Id; var addJobTitleToEmployeServiceModel = new AddJobTitleToEmployeServiceModel() { EmployeeId = userManager.GetUserId(user), JobTitleId = companyId }; employeeDataService.AddJobTitleToEployee(addJobTitleToEmployeServiceModel); } else { var companyId = jobTitleDataService.FindByName(name).Id; var addJobTitleToEmployeServiceModel = new AddJobTitleToEmployeServiceModel() { EmployeeId = userManager.GetUserId(user), JobTitleId = companyId }; employeeDataService.AddJobTitleToEployee(addJobTitleToEmployeServiceModel); } }
/// <summary> /// Creates View model for the acion /// </summary> /// <param name="model">EditUserViewModel which is a DTO which contains the needed info for this operations</param> /// <returns> EditUserServiceModel which is a DTO which contains the needed info for this operations</returns> public EditUserServiceModel EditUser(EditUserViewModel model) { var editUserServiceModel = new EditUserServiceModel() { FirstName = model.FirstName, MiddleName = model.MiddleName, LastName = model.LastName, Salary = model.Salary, HireDate = model.HireDate, IsEmployee = model.IsEmployee, IsManager = model.IsManager }; if (!jobTitleDataService.Exists(model.JobTitle)) { jobTitleDataService.CreateJobTitile(model.JobTitle); editUserServiceModel.JobTitleId = jobTitleDataService.FindByName(model.JobTitle).Id; } else { editUserServiceModel.JobTitleId = jobTitleDataService.FindByName(model.JobTitle).Id; } if (!depatmentDataService.Exists(model.Department)) { depatmentDataService.Create(model.Department); editUserServiceModel.DepartmentId = depatmentDataService.FindByName(model.Department).DepartmentId; } else { editUserServiceModel.DepartmentId = depatmentDataService.FindByName(model.Department).DepartmentId; } return(editUserServiceModel); }