public async Task <ActionResult <FoodMenuSubScreenForReturnDto> > Create(FoodMenuSubScreenForCreationDto creationDto) { var subscreen = await foodMenuSubScreenService.Create(creationDto); var onlineScreensByScreenId = await onlineScreenService.GetOnlineScreenConnectionIdByScreenId(subscreen.ScreenId); if (onlineScreensByScreenId != null && onlineScreensByScreenId.Length != 0) { await kiosksHub.Clients.Clients(onlineScreensByScreenId).SendAsync("ReloadScreen", true); } return(subscreen); }
public async Task <FoodMenuSubScreenForReturnDto> Update(FoodMenuSubScreenForCreationDto updateDto) { var checkByIdFromRepo = await foodMenuSubScreenDal.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 foodMenuSubScreenDal.Update(mapForUpdate); return(mapper.Map <FoodMenuSubscreen, FoodMenuSubScreenForReturnDto>(updatePhoto)); }
public async Task <FoodMenuSubScreenForReturnDto> Create(FoodMenuSubScreenForCreationDto creationDto) { var checkById = await foodMenuSubScreenDal.GetAsync(x => x.SubScreenId == creationDto.SubScreenId && x.FoodMenuId == creationDto.FoodMenuId); 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 foodMenuDal.GetAsync(x => x.Id == creationDto.FoodMenuId); 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 }); } var subScreenForReturn = new FoodMenuSubscreen() { SubScreenId = subScreenFromRepo.Id, ScreenId = screenFromRepo.Id, FoodMenuId = checkAnnounceFromRepo.Id, SubScreenName = subScreenFromRepo.Name, SubScreenPosition = subScreenFromRepo.Position }; var createSubScreen = await foodMenuSubScreenDal.Add(subScreenForReturn); var spec = new FoodMenuSubScreenWithSubScreenForReturnSpecification(createSubScreen.Id); var getFromRepo = await foodMenuSubScreenDal.GetEntityWithSpecAsync(spec); return(mapper.Map <FoodMenuSubscreen, FoodMenuSubScreenForReturnDto>(getFromRepo)); }