public IActionResult PinnedPost(int dealId) { string userId = User.Identity.GetUserId(); APIUser user = APIUser.Get(userId); PinnedDeal newPinnedDeal = new PinnedDeal(userId, dealId, user); PinnedDeal.Post(newPinnedDeal); return(RedirectToAction("Index", "Deals")); }
public void Post([FromBody] PinnedDeal pinnedDeal) { int dealId = pinnedDeal.DealId; string userId = pinnedDeal.UserId; if (_db.PinnedDeals.Where(entry => entry.DealId == dealId).Where(entry => entry.UserId == userId).ToList().Count() == 0) { _db.PinnedDeals.Add(pinnedDeal); } _db.SaveChanges(); }
public IActionResult Pinned(int id = 1) { try { string page = $"{id}"; ViewBag.Page = id; ViewBag.Size = 20; string userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; ViewBag.DealCount = PinnedDeal.GetCount(userId); var allPinnedDeals = PinnedDeal.GetAll(userId); return(View(allPinnedDeals)); } catch (Exception ex) { TempData["ErrorMessage"] = "You are not logged in. Please log in to see your pinned deals."; Console.WriteLine("Exception Error in Deals Controller Pinned Route: " + ex); return(View()); } }