public void LikePhoto(Photo photoModel, string UserId) { photoModel.NumberOfLikes++; photoModel.Likes.Add(new Like { UserId = UserId, UserName = _userRepo.Users.FirstOrDefault(c => c.Id == UserId).UserName }); _photoRepo.UpdatePhoto(photoModel); }
public ActionResult UpdatePhoto(int id, PhotoUpdateDto photoUpdateDto) { var photoModel = _repository.GetPhotosByFamilyMember(id); if (photoModel == null) { return(NotFound()); } _mapper.Map(photoUpdateDto, photoModel); _repository.UpdatePhoto(photoModel); _repository.SaveChanges(); return(NoContent()); }