예제 #1
0
        public async Task <FoodMenuPhotoForReturnDto> Update(FoodMenuPhotoForCreationDto updateDto)
        {
            var checkByIdFromRepo = await foodMenuPhotoDal.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 foodMenuPhotoDal.Update(mapForUpdate);

            return(mapper.Map <FoodMenuPhoto, FoodMenuPhotoForReturnDto>(updatePhoto));
        }
        public async Task <FoodMenuPhotoForReturnDto> Update(FoodMenuPhotoForCreationDto creationDto)
        {
            var photo = await foodMenuPhotoService.Update(creationDto);

            var connIds = await userTracker.GetOnlineUser();

            if (connIds != null && connIds.Length != 0)
            {
                await hubContext.Clients.GroupExcept("FoodMenu", connIds).SendAsync("ReceiveFoodMenuPhoto", photo, "update");
            }

            var onlineScreens = await onlineScreenService.GetAllOnlineScreenConnectionId();

            if (onlineScreens != null && onlineScreens.Length != 0)
            {
                await kiosksHub.Clients.Clients(onlineScreens).SendAsync("ReloadScreen", true);
            }

            return(photo);
        }
예제 #3
0
        public async Task <FoodMenuPhotoForReturnDto> Create(FileUploadDto uploadDto)
        {
            var checkAnnounceById = await foodMenuDal.GetAsync(x => x.Id == uploadDto.AnnounceId);

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

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

            var mapForCreate = new FoodMenuPhotoForCreationDto();

            mapForCreate.Name       = uploadFile.Name;
            mapForCreate.FullPath   = uploadFile.FullPath;
            mapForCreate.FoodMenuId = uploadDto.AnnounceId;
            mapForCreate.FileType   = uploadFile.FileType;
            mapForCreate.IsConfirm  = false;
            mapForCreate.UnConfirm  = false;
            var mapForDb    = mapper.Map <FoodMenuPhoto>(mapForCreate);
            var createPhoto = await foodMenuPhotoDal.Add(mapForDb);

            return(mapper.Map <FoodMenuPhoto, FoodMenuPhotoForReturnDto>(createPhoto));
        }