Пример #1
0
        public async Task <LiveTvListForReturnDto> Update(LiveTvListForCreationDto updateDto)
        {
            var checkById = await liveTvListDal.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 liveTvListDal.Update(mapForUpdate);

            return(mapper.Map <LiveTvList, LiveTvListForReturnDto>(mapForUpdate));
        }
Пример #2
0
        public async Task <LiveTvListForReturnDto> Create(LiveTvListForCreationDto createDto)
        {
            var checkByName = await liveTvListDal.GetAsync(x => x.TvName.ToLower() == createDto.TvName.ToLower());

            if (checkByName != null)
            {
                throw new RestException(HttpStatusCode.BadRequest, new { AlreadyExist = Messages.AlreadyExist });
            }

            var mapForCreate = mapper.Map <LiveTvList>(createDto);
            var saveToDb     = await liveTvListDal.Add(mapForCreate);

            var mapForReturn = mapper.Map <LiveTvList, LiveTvListForReturnDto>(saveToDb);

            return(mapForReturn);
        }
 public async Task <ActionResult <LiveTvListForReturnDto> > Update(LiveTvListForCreationDto updateDto)
 {
     return(await liveTvListService.Update(updateDto));
 }