public ActionResult ChangeInfoUser(RegisterUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (CheckOldPassword(model.ID, model.OldPassword))
                {
                    if (_iServiceUser.SaveEdit(GetUserModel(model)))
                    {
                        SessionUserHelper.CreateSessionSuccess(ConstantStrings.EditSuccess);
                    }
                    else
                    {
                        SessionUserHelper.CreateSessionError(ConstantStrings.EditNonSuccess);
                    }
                    var account = System.Web.HttpContext.Current.Session["Account"] as greenhousebanner.Models.ViewModels.Account;
                    if (!account.Username.Equals(model.Username))
                    {
                        return RedirectToAction("LogOut", "Account");
                    }

                    return RedirectToAction("Index", "Banner");
                }
                ViewBag.Error = "Mật khẩu cũ không chính xác.";
                return View(model);

            }
            return View(model);
        }
 public User GetUserModel(RegisterUserViewModel model)
 {
     var item = new User();
     item.Id = model.ID;
     item.Username = model.Username;
     item.Password = model.Password;
     item.IdRole = model.IdRole;
     item.Email = model.Email;
     item.Name = model.FullName;
     return item;
 }
        public ActionResult Edit(RegisterUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (CheckOldPassword(model.ID, model.OldPassword))
                {
                    if (_iServiceUser.SaveEdit(GetUserModel(model)))
                    {
                        SessionUserHelper.CreateSessionSuccess(ConstantStrings.EditSuccess);
                    }
                    else
                    {
                        SessionUserHelper.CreateSessionError(ConstantStrings.EditNonSuccess);
                    }
                    return RedirectToAction("Index");
                }
                ViewBag.Error = "Mật khẩu cũ không chính xác.";
                return View(model);

            }
            return View(model);
        }
 public RegisterUserViewModel GetModelRegisterUser(Guid id)
 {
     var model = _iServiceUser.GetItemUser(id);
     var item = new RegisterUserViewModel();
     item.ID = model.Id;
     item.Username = model.Username;
     item.Password = model.Password;
     item.IdRole = model.IdRole;
     item.FullName = model.Name;
     item.Email = model.Email;
     return item;
 }
        public ActionResult Create(RegisterUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new User();

                user.Username = model.Username;
                user.Password = MD5Helper.Encrypt(model.ConfirmPassword, true);
                user.Name = model.FullName;
                user.Email = model.Email;
                //user.Password = MD5Helper.Encrypt(model.ConfirmPassword);
                user.IdRole = model.IdRole;
                if (_iServiceUser.SaveAdd(user))
                {
                    SessionUserHelper.CreateSessionSuccess(ConstantStrings.AddSuccess);
                }
                else
                {
                    SessionUserHelper.CreateSessionError(ConstantStrings.AddNonSuccess);
                }
                return RedirectToAction("Index");
            }
            return View(model);
        }