예제 #1
0
        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));
        }
예제 #2
0
        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);
        }
예제 #3
0
 public async Task <ActionResult <DegreeForReturnDto> > Update(DegreeForCreationDto updateDto)
 {
     return(await degreeService.Update(updateDto));
 }