예제 #1
0
        public IActionResult GridViewPartialUpdate(UserIdentity.Models.AppUser item)
        {
            var db = HttpContext.RequestServices.GetService(typeof(UserIdentity.Models.AppIdentityDbContext)) as UserIdentity.Models.AppIdentityDbContext;

            try
            {
                if (ModelState.IsValid)
                {
                    db.Users.Update(item);
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                ViewData["error"] = e.Message;
            }
            return(PartialView("~/Views/Admin/GridViewPartial.cshtml", db.Users));
        }
예제 #2
0
        public IActionResult GridViewPartialAddNew(UserIdentity.Models.AppUser item)
        {
            var db = HttpContext.RequestServices.GetService(typeof(UserIdentity.Models.AppIdentityDbContext)) as UserIdentity.Models.AppIdentityDbContext;

            try
            {
                if (ModelState.IsValid)
                {
                    item.Id = db.Users.Max(p => p.Id) + 1; // Remove this line if your Primary Key is automatically incremented at your database/model level
                    db.Users.Add(item);
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                ViewData["error"] = e.Message;
            }
            return(PartialView("~/Views/Admin/GridViewPartial.cshtml", db.Users));
        }