public async Task <List <LiveTvBroadCastSubScreenForReturnDto> > GetListAsync() { var getListFromRepo = await liveTvBroadCastSubScreenDal.GetListAsync(); if (getListFromRepo == null) { throw new RestException(HttpStatusCode.BadRequest, new { NotFound = Messages.NotFound }); } return(mapper.Map <List <LiveTvBroadCastSubScreen>, List <LiveTvBroadCastSubScreenForReturnDto> >(getListFromRepo)); }
public async Task <LiveTvBroadCastForReturnDto> Publish(LiveTvBroadCastForCreationDto updateDto) { var checkFromRepo = await liveTvBrodcastDal.GetAsync(x => x.Id == updateDto.Id); if (checkFromRepo == null) { throw new RestException(HttpStatusCode.BadRequest, new { NotFound = Messages.NotFound }); } var checkHomeAnnounceSubScreenForPublish = await liveTvBroadCastSubScreenDal.GetListAsync(x => x.LiveTvBroadCastId == updateDto.Id); if (checkHomeAnnounceSubScreenForPublish.Count <= 0) { throw new RestException(HttpStatusCode.BadRequest, new { NotSelectSubScreen = Messages.NotSelectSubScreen }); } if (updateDto.IsPublish) { var checkDateExpire = DateTime.Compare(DateTime.Now, checkFromRepo.PublishFinishDate); if (checkDateExpire > 0) { throw new RestException(HttpStatusCode.BadRequest, new { NotFound = Messages.PublishDateExpire }); } } var mapForUpdate = mapper.Map(updateDto, checkFromRepo); mapForUpdate.Updated = DateTime.Now; mapForUpdate.SlideIntervalTime = (int)TimeSpan.FromMinutes(mapForUpdate.SlideIntervalTime).TotalSeconds; await liveTvBrodcastDal.Update(mapForUpdate); var spec = new LiveTvBroadCastWithUserSpecification(updateDto.Id); var getAnnounceWithUserFromRepo = await liveTvBrodcastDal.GetEntityWithSpecAsync(spec); return(mapper.Map <LiveTvBroadCast, LiveTvBroadCastForReturnDto>(getAnnounceWithUserFromRepo)); }