示例#1
0
        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));
        }
示例#2
0
        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));
        }