Exemple #1
0
 public IHttpActionResult AddLike(PhotoDTO photo)
 {
     if (photo != null)
     {
         myPhotoService.AddLike(photo);
         photo = myPhotoService.GetById(photo.PhotoId);
         return(Ok(photo));
     }
     else
     {
         return(new StatusCodeResult(HttpStatusCode.MethodNotAllowed, this));
     }
 }
        public HttpResponseMessage AddLike([FromBody] int photoId)
        {
            try
            {
                _photoService.AddLike(User.Id, photoId);

                // TODO COSTIL
                List <PhotoLikeViewModel> photoLikeViewModels = _photoService
                                                                .GetLikes(User.Id, photoId)
                                                                .Select(model => model.ToPhotoLikeViewModel())
                                                                .ToList();

                return(Request.CreateResponse(HttpStatusCode.Created, photoLikeViewModels, new JsonMediaTypeFormatter()));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }