public async Task <DegreeForReturnDto> Update(DegreeForCreationDto updateDto) { var checkById = await titleDal.GetAsync(x => x.Id == updateDto.Id); if (checkById == null) { throw new RestException(HttpStatusCode.BadRequest, new { NotFound = Messages.NotFound }); } var mapForUpdate = mapper.Map(updateDto, checkById); await titleDal.Update(mapForUpdate); return(mapper.Map <Degree, DegreeForReturnDto>(mapForUpdate)); }
public async Task <DegreeForReturnDto> Create(DegreeForCreationDto createDto) { var checkByName = await titleDal.GetAsync(x => x.Name.ToLower() == createDto.Name.ToLower()); if (checkByName != null) { throw new RestException(HttpStatusCode.BadRequest, new { AlreadyExist = Messages.AlreadyExist }); } var mapForCreate = mapper.Map <Degree>(createDto); var saveToDb = await titleDal.Add(mapForCreate); var mapForReturn = mapper.Map <Degree, DegreeForReturnDto>(saveToDb); return(mapForReturn); }
public async Task <ActionResult <DegreeForReturnDto> > Update(DegreeForCreationDto updateDto) { return(await degreeService.Update(updateDto)); }