public ActionResult ShowPhoto(int id) { try { int currentUserId = _repository.GetCurrentUserId(); var temp = _repository.FindPicture(id); var model = new PictureViewModel() { Id = temp.Id, Name = temp.Name, Like = temp.Likes.SingleOrDefault(j => j.UserId == currentUserId && j.PictureId == temp.Id), Url = "", UserEmail = temp.User.Email }; return View(model); } catch (Exception exception) { return PartialView("_Error", exception); } }
public PartialViewResult Like(int id) { try { int currentUserId = _repository.GetCurrentUserId(); _repository.CreateLike(id, currentUserId); var temp = _repository.FindPicture(id); var model = new PictureViewModel() { Id = temp.Id, Name = temp.Name, Like = temp.Likes.SingleOrDefault(j => j.UserId == currentUserId && j.PictureId == temp.Id), Url = "" }; return PartialView("_Buttons", model); } catch (Exception exception) { return PartialView("_Error", exception); } }