public virtual ActionResult Update([DataSourceRequest] DataSourceRequest request, UserViewModel item) { LogI("Update, item=" + item); if (ModelState.IsValid && item != null) { var validationResults = item.Validate(Db); if (validationResults.Any()) { validationResults.Each(v => ModelState.AddModelError("", v.Message)); } else { if (AccessManager.CompanyId.HasValue) { item.Apply(Db, AccessManager.CompanyId.Value, Time.GetAppNowTime(), AccessManager.UserId); } } } return(Json((new[] { item }).ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> Create([Bind("ID,Login,Password")] UserViewModel model) { if (ModelState.IsValid) { var user = new User(); model.Apply(user); _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(model)); }