public async Task <ActionResult> Post(EmploymentTypeCreateDto employmentTypeCreateDto) { var mappedModel = _mapper.Map <EmploymentType>(employmentTypeCreateDto); await _employmentTypeRepo.CreateEmploymentTypeAsync(mappedModel); await _employmentTypeRepo.SaveAsync(); return(Ok()); }
public async Task <IActionResult> CreateEmployemntType([FromBody] EmploymentTypeCreateDto employmentTypeCreateDto) { var employmentType = _mapper.Map <EmploymentType>(employmentTypeCreateDto); await _unitOfWork.EmployementType.Insert(employmentType); await _unitOfWork.Save(); return(CreatedAtRoute("GetEmploymentTypeById", new { id = employmentType.EmploymentTypeId }, employmentType)); }
public async Task <ActionResult> Put(int id, EmploymentTypeCreateDto employmentTypeCreateDto) { try { var employmentType = await _employmentTypeRepo.GetEmploymentTypeByIdAsync(id); if (employmentType is null) { return(NotFound()); } var newEmploymentType = _mapper.Map(employmentTypeCreateDto, employmentType); _employmentTypeRepo.UpdateEmploymentTypeAsync(id, employmentType); await _employmentTypeRepo.SaveAsync(); return(Ok(newEmploymentType)); } catch (Exception) { throw; } }