public async Task <IActionResult> Edit(int id, [Bind("DinnerId,Title,EventDate,Description,HostedBy,ContactPhone,Address,Country,Latitude,Longitude")] BookDinner dinner) { ViewData["session"] = HttpContext.Session.GetString("userId"); if (id != dinner.DinnerId) { return(View("NotFound")); } if (ModelState.IsValid) { try { _context.Update(dinner); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DinnerExists(dinner.DinnerId)) { return(View("NotFound")); } else { throw; } } return(RedirectToAction(nameof(Logged))); } return(View(dinner)); }
public async Task <IActionResult> Create([Bind("DinnerId,Title,EventDate,Description,HostedBy,ContactPhone,Address,Country,Latitude,Longitude")] BookDinner dinner) { ViewData["session"] = HttpContext.Session.GetString("userId"); var uid = int.Parse(HttpContext.Session.GetString("Uid")); if (ModelState.IsValid) { dinner.CreatorId = uid; _context.Add(dinner); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Logged))); } return(View(dinner)); }