public ActionResult MyFavorites() { AllEvents all = new AllEvents(); var currentUser = manager.FindById(User.Identity.GetUserId()); all._events = db.Events.ToList(); all._favorites = db.Favorites.Where(t => t.User.Id == currentUser.Id).ToList(); var events = all.ReturnFavoriteEvents(); return(PartialView(events)); }
public ActionResult EventPage(int?id) { if (id == null) { // возвращает экземпляр класса HttpNotFound return(HttpNotFound()); } var currentUser = manager.FindById(User.Identity.GetUserId()); AllEvents all = new AllEvents(); all._events = db.Events.ToList(); all._favorites = db.Favorites.Where(t => t.User.Id == currentUser.Id).ToList(); var events = all.ReturnFavoriteEvents(); bool check = false; int compare = 0; Event @event = db.Events.FirstOrDefault(t => t.Id == id); if (events.Count != 0) { if (events.Contains(@event)) { check = true; } else { check = false; } } if (currentUser.Equals(@event.User)) { compare = 1; } ViewBag.Compare = compare; ViewBag.CompareMessage = "Вы не можете добавить это событие в избранное так как вы являетесь его создателем"; ViewBag.Check = check; ViewBag.MessageCheck = "Это событие уже находиться в ваших избранных"; return(View(@event)); }