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)); }