public async Task <LiveTvBroadCastForReturnDto> Create(LiveTvBroadCastForCreationDto creationDto) { var checkByNameFromRepo = await liveTvBrodcastDal.GetAsync(x => x.Header.ToLower() == creationDto.Header.ToLower()); if (checkByNameFromRepo != null) { throw new RestException(HttpStatusCode.BadRequest, new { AlreadyExist = Messages.AlreadyExist }); } var userId = (int)httpContextAccessor.HttpContext.User?.ClaimsId(); var mapForCreate = mapper.Map <LiveTvBroadCast>(creationDto); var slideId = Guid.NewGuid(); mapForCreate.SlideId = slideId; mapForCreate.UserId = userId; mapForCreate.SlideIntervalTime = (int)TimeSpan.FromMinutes(mapForCreate.SlideIntervalTime).TotalSeconds; mapForCreate.Created = DateTime.Now; mapForCreate.AnnounceType = "livetv"; var createAnnounce = await liveTvBrodcastDal.Add(mapForCreate); var spec = new LiveTvBroadCastWithUserSpecification(createAnnounce.Id); var getAnnounceFromRepo = await liveTvBrodcastDal.GetEntityWithSpecAsync(spec); return(mapper.Map <LiveTvBroadCast, LiveTvBroadCastForReturnDto>(getAnnounceFromRepo)); }
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)); }