public async Task <ScreenHeaderPhotoForReturnDto> SetMain(ScreenHeaderPhotoForCreationDto creationDto)
        {
            var photo = await screenHeaderPhotoService.SetMain(creationDto);

            var onlineScreens = await onlineScreenService.GetOnlineScreenConnectionIdByScreenId(photo.ScreenId);

            if (onlineScreens != null && onlineScreens.Length != 0)
            {
                await kiosksHub.Clients.Clients(onlineScreens).SendAsync("ReceiveScreenHeaderPhoto", photo);
            }
            return(photo);
        }
예제 #2
0
        public async Task <ScreenHeaderPhotoForReturnDto> Update(ScreenHeaderPhotoForCreationDto updateDto)
        {
            var checkByIdFromRepo = await screenHeaderPhotoDal.GetAsync(x => x.Id == updateDto.Id);

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

            var mapForUpdate = mapper.Map(updateDto, checkByIdFromRepo);

            if (mapForUpdate.IsMain)
            {
                mapForUpdate.IsMain = false;
            }
            var updatePhoto = await screenHeaderPhotoDal.Update(mapForUpdate);

            return(mapper.Map <ScreenHeaderPhoto, ScreenHeaderPhotoForReturnDto>(updatePhoto));
        }
예제 #3
0
        public async Task <ScreenHeaderPhotoForReturnDto> SetMain(ScreenHeaderPhotoForCreationDto updateDto)
        {
            var checkByIdFromRepo = await screenHeaderPhotoDal.GetAsync(x => x.Id == updateDto.Id);

            if (checkByIdFromRepo == null)
            {
                throw new RestException(HttpStatusCode.BadRequest, new { NotFound = Messages.NotFound });
            }
            var getAlreadyIsMain = await screenHeaderPhotoDal
                                   .GetAsync(x => x.IsMain == true && x.Position.ToLower() == updateDto.Position.ToLower() && x.ScreenId == updateDto.ScreenId);

            if (getAlreadyIsMain != null)
            {
                getAlreadyIsMain.IsMain = false;
                await screenHeaderPhotoDal.Update(getAlreadyIsMain);
            }


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

            return(mapper.Map <ScreenHeaderPhoto, ScreenHeaderPhotoForReturnDto>(updatePhoto));
        }
예제 #4
0
        public async Task <ScreenHeaderPhotoForReturnDto> Create(FileUploadDto uploadDto)
        {
            var checkAnnounceById = await screenDal.GetAsync(x => x.Id == uploadDto.AnnounceId);

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

            var uploadFile = await upload.Upload(uploadDto.File, "headerphoto");


            var mapForCreate = new ScreenHeaderPhotoForCreationDto();

            mapForCreate.Name     = uploadFile.Name;
            mapForCreate.FullPath = uploadFile.FullPath;
            mapForCreate.ScreenId = checkAnnounceById.Id;
            mapForCreate.FileType = uploadFile.FileType;
            mapForCreate.IsMain   = false;
            var mapForDb    = mapper.Map <ScreenHeaderPhoto>(mapForCreate);
            var createPhoto = await screenHeaderPhotoDal.Add(mapForDb);

            return(mapper.Map <ScreenHeaderPhoto, ScreenHeaderPhotoForReturnDto>(createPhoto));
        }
 public async Task <ScreenHeaderPhotoForReturnDto> Update(ScreenHeaderPhotoForCreationDto creationDto)
 {
     return(await screenHeaderPhotoService.Update(creationDto));
 }