コード例 #1
0
        public ActionResult CreatePhoto(SavePhotoRequest request)
        {
            try
            {
                var photoRequest = Mapper.Map <PhotoDTO>(request.Photo);

                var photoLinks = "";
                foreach (var link in photoRequest.PhotoRef.ToList())
                {
                    photoLinks += link + ";";
                }

                var photo = new Photo
                {
                    BrandId  = photoRequest.BrandId,
                    MenuId   = photoRequest.MenuId,
                    PhotoRef = photoLinks
                };

                _serviceUow.BrandService.SavePhoto(photo);

                return(NoContent());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
コード例 #2
0
        public override async Task <SavePhotoReply> SavePhoto(SavePhotoRequest request, ServerCallContext context)
        {
            var photo         = _mapper.Map <Photo>(request.Photo);
            var responsePhoto = await _photoService.SavePhotoAsync(photo);

            return(new SavePhotoReply
            {
                Photo = _mapper.Map <PhotoMessage>(responsePhoto)
            });
        }
コード例 #3
0
        public async Task <Photo> SavePhotoAsync(Photo photo)
        {
            var request = new SavePhotoRequest
            {
                Photo = _mapper.Map <PhotoMessage>(photo)
            };
            var reply = await _client.SavePhotoAsync(request);

            return(_mapper.Map <Photo>(reply.Photo));
        }