public IResult Add(WorkerCreationDto workerCreationDto) { var workerMapper = _mapper.Map <Worker>(workerCreationDto); workerMapper.Status = true; _workerDal.Add(workerMapper); foreach (var departmentType in workerCreationDto.DepartmentTypes) { WorkerDepartmentType workerDepartmentType = new WorkerDepartmentType { DepartmentTypeID = departmentType.DepartmentTypeID, WorkerID = workerMapper.WorkerID }; _workerDepartmentTypeService.Add(workerDepartmentType); } Salary salary = new Salary() { WorkerID = workerMapper.WorkerID, UserID = workerCreationDto.UserID, SalaryAmount = 0, }; _salaryService.Add(salary); return(new SuccessResult(Messages.WorkerAdded)); }
public ActionResult Add(WorkerCreationDto workerCreationDto) { var result = _workerService.Add(workerCreationDto); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }