コード例 #1
0
        public async Task <IActionResult> GetDinnerAsync(int id)
        {
            var dinner = await _repository.GetDinnerAsync(id);

            if (dinner == null)
            {
                return(View("Error"));
            }

            return(new ObjectResult(dinner));
        }
コード例 #2
0
        public async Task <IActionResult> GetDinnerAsync(int id)
        {
            var dinner = await _repository.GetDinnerAsync(id);

            if (dinner == null)
            {
                return(HttpNotFound());
            }

            return(new ObjectResult(dinner));
        }
コード例 #3
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));
        }
コード例 #4
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));
        }
コード例 #5
0
        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));
        }