コード例 #1
0
ファイル: UsersController.cs プロジェクト: jhone18/Payroll
        public JsonResult Edit(string jsonData)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Users user          = JsonConvert.DeserializeObject <Users>(jsonData);
                    var   usersToUpdate = _context.Users.Where(u => u.UserId == user.UserId).FirstOrDefault();
                    user.Application = usersToUpdate.Application;
                    user.Password    = usersToUpdate.Password;

                    _context.Entry(usersToUpdate).CurrentValues.SetValues(user);

                    // TODO: Add update logic here
                    //_context.Update(user);
                    _context.SaveChanges();
                }

                return(Json(new { Success = true }));
            }
            catch
            {
                throw;
            }
        }
コード例 #2
0
        public JsonResult Edit(string role)
        {
            try
            {
                // TODO: Add update logic here

                if (ModelState.IsValid)
                {
                    Roles roleObj      = JsonConvert.DeserializeObject <Roles>(role);
                    var   roleToUpdate = _context.Roles.Where(r => r.RoleId == roleObj.RoleId).FirstOrDefault();
                    roleObj.Application = roleToUpdate.Application;

                    _context.Entry(roleToUpdate).CurrentValues.SetValues(roleObj);

                    // TODO: Add update logic here
                    //_context.Update(user);
                    _context.SaveChanges();
                }

                return(Json(new { Success = true }));
            }
            catch
            {
                throw;
            }
        }