コード例 #1
0
        public void Edit(PhotoEditDTO photoInfo)
        {
            var photo = context.Photos.Find(photoInfo.PhotoId);

            if (photo.UserId != photoInfo.UserId)
            {
                throw new UnauthorizedException();
            }
            photo.Name        = photoInfo.Title;
            photo.Description = photoInfo.Description;
            context.SaveChanges();
        }
コード例 #2
0
        public IHttpActionResult EditPhotoInfo(int id, [FromBody] PhotoEditViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException();
            }

            var photoInfo = new PhotoEditDTO()
            {
                Title       = model.Title,
                Description = model.Description,
                UserId      = User.Identity.GetUserId(),
                PhotoId     = id
            };

            Service.Edit(photoInfo);
            return(Ok());
        }