コード例 #1
0
        public virtual async Task <IActionResult> Create(T entity)
        {
            RemoveNavigationPropertiesFromModelState <T>();
            if (ModelState.IsValid)
            {
                ViewHelpers.RemoveAllNavigationProperties(entity);

                // Add entity to entity list in contest
                var contest    = SelectedContest.Include(EntitiesInContestExpression()).Single();
                var entityList = EntitiesInContestExpression().Compile()(contest);
                entityList.Add(entity);

                await DbContext.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToAction(nameof(Index)));
            }

            AddEntityListsToViewBag();
            return(View(entity));
        }