public async Task <IActionResult> GetDinnerAsync(int id) { var dinner = await _repository.GetDinnerAsync(id); if (dinner == null) { return(View("Error")); } return(new ObjectResult(dinner)); }
public async Task <IActionResult> GetDinnerAsync(int id) { var dinner = await _repository.GetDinnerAsync(id); if (dinner == null) { return(HttpNotFound()); } return(new ObjectResult(dinner)); }
public async Task <IActionResult> CreateRsvpAsync(int dinnerId) { var dinner = await _repository.GetDinnerAsync(dinnerId); if (dinner == null) { return(HttpNotFound()); } var user = await _userManager.FindByIdAsync(Context.User.GetUserId()); var rsvp = await _repository.CreateRsvpAsync(dinner, user.UserName); return(new JsonResult(rsvp)); }
public async Task <IActionResult> CreateRsvpAsync(int dinnerId) { var dinner = await _repository.GetDinnerAsync(dinnerId); if (dinner == null) { return(View("Error")); } var user = await _userManager.FindByNameAsync(HttpContext.User.Identity.Name); var rsvp = await _repository.CreateRsvpAsync(dinner, user.UserName); return(new JsonResult(rsvp)); }
public async Task <IActionResult> Detail(int id) { Dinner dinner = await _repository.GetDinnerAsync(id); if (dinner == null) { return(NotFound()); } try { var user = await _userManager.FindByNameAsync(HttpContext.User.Identity.Name); ViewBag.isHost = dinner.IsUserHost(user.UserName); } catch (ArgumentNullException e) { ViewBag.isHost = false; } return(View(dinner)); }