コード例 #1
0
        public async Task <IActionResult> AddEvent(Event newEvent)
        {
            //  if (!ModelState.IsValid)
            //  {
            //      return RedirectToAction("Index");
            //  }

            var currentUser = await _userManager.GetUserAsync(User);

            if (currentUser == null)
            {
                return(RedirectToAction("Index"));
            }

            var successful = await _eventService.AddEventAsync(newEvent, currentUser);

            if (!successful)
            {
                return(BadRequest("Could not add item."));
            }

            return(RedirectToAction("Index"));
        }