コード例 #1
0
        public async Task <IActionResult> Update([DataSourceRequest] DataSourceRequest request, AuthenticationTypeViewModel viewModel)
        {
            var model = db.AuthenticationTypes.First(n => n.AuthenticationTypeId == viewModel.AuthenticationTypeId);

            if (ModelState.IsValid)
            {
                await this.TryUpdateModelAsync <AuthenticationTypeViewModel, AuthenticationType>(model, "", m => { return(m.ElementType == null); });

                await db.SaveChangesAsync();
            }

            return(Json(await new[] { model.ToViewModel <AuthenticationType, AuthenticationTypeViewModel>() }.ToDataSourceResultAsync(request, ModelState)));
        }
コード例 #2
0
        public async Task <IActionResult> Destroy([DataSourceRequest] DataSourceRequest request, AuthenticationTypeViewModel viewModel)
        {
            db.ShowAllTenants = true;
            var model = db.AuthenticationTypes.First(n => n.AuthenticationTypeId == viewModel.AuthenticationTypeId);

            if (ModelState.IsValid)
            {
                db.AuthenticationTypes.Remove(model);
                await db.SaveChangesAsync();
            }

            return(Json(await new[] { viewModel }.ToDataSourceResultAsync(request, ModelState)));
        }