コード例 #1
0
        public async Task <IActionResult> JoinEvent(Guid id)
        {
            var currenEvent = await _eventService.GetEvent(id);

            var currentUser = await _userManager.GetUserAsync(User);

            if (currenEvent.CurrentPeopleNumber < currenEvent.HowManyPeople)
            {
                currenEvent.CurrentPeopleNumber++;
                var successful = await _eventService.JoinEventAsync(currenEvent, currentUser);

                if (!successful)
                {
                    return(RedirectToAction("Index"));
                }
            }
            return(RedirectToAction("Index"));
        }