public async Task <IActionResult> Edit(int id, UserViewModel userVM)
        {
            if (id != userVM.Id)
            {
                return(NotFound());
            }

            User user = null;

            if (ModelState.IsValid)
            {
                try
                {
                    user = await _context.User.Include(u => u.UserRole).FirstOrDefaultAsync(t => t.Id == id);

                    user.CreatedDate = DateTime.Now;
                    user.Email       = userVM.Email;
                    user.UserRoleId  = int.Parse(userVM.UserRoleId);
                    user.FirstName   = userVM.FirstName;
                    user.LastName    = userVM.LastName;
                    user.IsActive    = userVM.IsActive;

                    if (user.UserRoleId == 1)
                    {
                        user.ExpireDate = DateTime.Now.AddMonths(3);
                    }
                    else
                    {
                        user.ExpireDate = DateTime.Now.AddYears(1);
                    }


                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Level")] UserRole userRole)
        {
            if (id != userRole.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(userRole);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserRoleExists(userRole.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(userRole));
        }