Пример #1
0
        public async Task <LiveTvBroadCastSubScreenForReturnDto> Create(LiveTvBroadCastSubScreenForCreationDto creationDto)
        {
            var checkById = await liveTvBroadCastSubScreenDal.GetAsync(x => x.SubScreenId == creationDto.SubScreenId && x.LiveTvBroadCastId == creationDto.LiveTvBroadCastId);

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

            var subScreenFromRepo = await subSCreenDal.GetAsync(x => x.Id == creationDto.SubScreenId);

            if (subScreenFromRepo == null)
            {
                throw new RestException(HttpStatusCode.BadRequest, new { NotFound = Messages.NotFoundSubSCreen });
            }

            var checkAnnounceFromRepo = await liveTvBroadCastDal.GetAsync(x => x.Id == creationDto.LiveTvBroadCastId);

            if (checkAnnounceFromRepo == null)
            {
                throw new RestException(HttpStatusCode.BadRequest, new { NotFound = Messages.NotFoundAnnounce });
            }

            var screenFromRepo = await screenDal.GetAsync(x => x.Id == creationDto.ScreenId);

            if (screenFromRepo == null)
            {
                throw new RestException(HttpStatusCode.BadRequest, new { NotFound = Messages.NotFoundScreen });
            }

            if (!checkAnnounceFromRepo.IsPublish)
            {
                throw new RestException(HttpStatusCode.BadRequest, new { NotFound = "Canlı Tv yayını henüz onay bekliyor...." });
            }

            var subScreenForReturn = new LiveTvBroadCastSubScreen()
            {
                SubScreenId       = subScreenFromRepo.Id,
                ScreenId          = screenFromRepo.Id,
                LiveTvBroadCastId = checkAnnounceFromRepo.Id,
                SubScreenName     = subScreenFromRepo.Name,
                SubScreenPosition = subScreenFromRepo.Position
            };

            var createSubScreen = await liveTvBroadCastSubScreenDal.Add(subScreenForReturn);

            var spec        = new LiveTvBroadCastSubScreenWithSubScreenForReturnSpecification(createSubScreen.Id);
            var getFromRepo = await liveTvBroadCastSubScreenDal.GetEntityWithSpecAsync(spec);

            return(mapper.Map <LiveTvBroadCastSubScreen, LiveTvBroadCastSubScreenForReturnDto>(getFromRepo));
        }
Пример #2
0
        public async Task <LiveTvBroadCastSubScreenForReturnDto> Update(LiveTvBroadCastSubScreenForCreationDto updateDto)
        {
            var checkByIdFromRepo = await liveTvBroadCastSubScreenDal.GetAsync(x => x.Id == updateDto.Id);

            if (checkByIdFromRepo == null)
            {
                throw new RestException(HttpStatusCode.BadRequest, new { NotFound = Messages.NotFound });
            }

            var mapForUpdate = mapper.Map(updateDto, checkByIdFromRepo);
            var updatePhoto  = await liveTvBroadCastSubScreenDal.Update(mapForUpdate);

            return(mapper.Map <LiveTvBroadCastSubScreen, LiveTvBroadCastSubScreenForReturnDto>(updatePhoto));
        }
Пример #3
0
 public async Task <ActionResult <LiveTvBroadCastSubScreenForReturnDto> > Create(LiveTvBroadCastSubScreenForCreationDto creationDto)
 {
     return(await liveTvBroadCastSubSreenService.Create(creationDto));
 }