示例#1
0
        public ActionResult Login(string txtUser, string txtPass)
        {
            var loginUser = new CodeLogin();
            var usercode  = new CodeUser();
            var result    = loginUser.LoginAccount(txtUser, Encryptor.MD5Hash(txtPass));

            if (result == 1)
            {
                var user = usercode.GetByID(txtUser.Trim());
                ViewBag.Hoten = user.Name;
                var userSession = new UserLogin();
                userSession.UserID   = user.ID;
                userSession.UserName = user.UserName;
                Session.Add(CommonConstants.USER_SESSION, userSession);
                return(RedirectToAction("Index", "Home"));
            }
            else if (result == 0)
            {
                ModelState.AddModelError("", "Tài khoản không tồn tại !");
            }
            else if (result == -1)
            {
                ModelState.AddModelError("", "Tài khoản bị khóa !");
            }
            else if (result == -2)
            {
                ModelState.AddModelError("", "Mật khẩu không đúng !");
            }


            return(View("Login"));
        }
示例#2
0
        public ActionResult Edit(User user)
        {
            if (ModelState.IsValid)
            {
                var edituser = new CodeUser();
                if (!string.IsNullOrEmpty(user.Password))
                {
                    var mahoapass = Encryptor.MD5Hash(user.Password);
                    user.Password = mahoapass;
                }
                var result = edituser.Update(user);
                if (result)
                {
                    RedirectToAction("Index", "User");
                }
                else
                {
                    ModelState.AddModelError("", "Cập nhập User không thành công !");
                }
                return(RedirectToAction("Index"));
            }

            else
            {
                SetViewGroup(user.GroupID);
                return(View(user));
            }
        }
示例#3
0
        public ActionResult Edit(int id)
        {
            var user = new CodeUser().ViewDetail(id);

            SetViewGroup(user.GroupID);
            return(View(user));
        }
示例#4
0
 public ActionResult Create(User user)
 {
     if (ModelState.IsValid)
     {
         var addUser   = new CodeUser();
         var Mahoapass = Encryptor.MD5Hash(user.Password);
         user.Password    = Mahoapass;
         user.CreatedDate = DateTime.Now;
         user.Status      = true;
         long Id = addUser.Insert(user);
         if (Id > 0)
         {
             RedirectToAction("Index", "User");
         }
         else
         {
             ModelState.AddModelError("", "Thêm mới User không thành công !");
         }
         return(RedirectToAction("Index"));
     }
     else
     {
         SetViewGroup(null);
         return(View(user));
     }
 }
示例#5
0
        // GET: Admin/User
        public ActionResult Index(string searchString, int page = 1, int pagesize = 5)
        {
            var user  = new CodeUser();
            var model = user.ListPaging(searchString, page, pagesize);

            ViewBag.searchString = searchString;
            return(View(model));
        }
示例#6
0
        public JsonResult ChangeStatus(long Id)
        {
            var result = new CodeUser().ChangeStatus(Id);

            return(Json(new
            {
                status = result
            }));
        }
示例#7
0
        public ActionResult Login(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                var loginUser = new CodeLogin();
                var usercode  = new CodeUser();
                var result    = loginUser.Login(model.UserName, model.Password, true);
                if (result == 1)
                {
                    var user = usercode.GetByID(model.UserName);
                    ViewBag.Hoten = user.Name;
                    var userSession = new UserLogin();
                    userSession.UserID   = user.ID;
                    userSession.UserName = user.UserName;
                    userSession.GroupID  = user.GroupID;

                    Session.Add(CommonConstants.USER_SESSION, userSession);
                    List <string> listRole = db.Database.SqlQuery <string>("exec GetPermissionByUserId " + user.ID.ToString()).ToList();
                    Session["strRole"] = listRole;
                    if (user.GroupID == "1")
                    {
                        return(RedirectToAction("PermissionGroup", "Permission"));
                    }
                    else if (user.GroupID == "2")
                    {
                        return(RedirectToAction("Index", "Product"));
                    }
                    else if (user.GroupID == "3")
                    {
                        return(RedirectToAction("Index", "Order"));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else if (result == 0)
                {
                    ModelState.AddModelError("", "Tài khoản không tồn tại !");
                }
                else if (result == -1)
                {
                    ModelState.AddModelError("", "Tài khoản bị khóa !");
                }
                else if (result == -2)
                {
                    ModelState.AddModelError("", "Mật khẩu không đúng !");
                }
                else if (result == -3)
                {
                    ModelState.AddModelError("", "Bạn không có quyền truy cập !");
                }
            }

            return(View("Index"));
        }
 public ActionResult Edit(CodeUser codeUser)
 {
     if (ModelState.IsValid)
     {
         unitOfWork.codeUsersRepository.Update(codeUser);
         unitOfWork.Save();
         return(RedirectToAction("Index", "CodeUser"));
     }
     return(View(codeUser));
 }
        public ActionResult Create(CodeUser codeUser)
        {
            if (ModelState.IsValid)
            {
                codeUser.Password = CommonTools.ToMd5(codeUser.Password);
                unitOfWork.codeUsersRepository.Insert(codeUser);
                unitOfWork.Save();
                return(RedirectToAction("Index", "CodeUser"));
            }

            return(View(codeUser));
        }
        public ActionResult Edit(int id)
        {
            CategoryService cate = new CategoryService();

            ViewData["Categorylist"] = cate.GetCategorySelectList(5);
            CodeUser codeUser = unitOfWork.codeUsersRepository.GetByID(id);

            if (codeUser == null)
            {
                return(HttpNotFound());
            }
            return(View(codeUser));
        }
        public ActionResult SetPassWord(FormCollection fc)
        {
            CodeUser coder = unitOfWork.codeUsersRepository.GetByID(int.Parse(Session["coderid"].ToString()));

            string oldPassword    = CommonTools.ToMd5(fc["oldPassword"].ToString());
            string newPassword    = fc["newPassword"];
            string repeatPassword = fc["repeatPassword"];
            string password       = coder.Password;

            if (oldPassword == password && newPassword == repeatPassword)
            {
                coder.Password = CommonTools.ToMd5(fc["newPassword"].ToString());
                unitOfWork.codeUsersRepository.Update(coder);
                unitOfWork.Save();
                return(RedirectToAction("Index", "Home"));
            }
            ViewBag.msg = "原密码不对或两次输入的新密码不一致";
            return(View());
        }
        public JsonResult UpdateStatus(int?id, bool status)
        {
            Message msg = new Message();

            if (id == null)
            {
                msg.MessageStatus = "false";
                msg.MessageInfo   = "找不到ID";
            }
            CodeUser codeUser = unitOfWork.codeUsersRepository.GetByID(id);

            codeUser.UserStatus = status;
            if (ModelState.IsValid)
            {
                unitOfWork.codeUsersRepository.Update(codeUser);
                unitOfWork.Save();
                msg.MessageStatus = "true";
                msg.MessageInfo   = "已经更改为" + codeUser.UserStatus.ToString();
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
示例#13
0
        public IActionResult SetCode([FromBody] CodeUser codeUser)
        {
            TimeZoneInfo zone     = TimeZoneInfo.FindSystemTimeZoneById("SE Asia Standard Time");
            DateTime     dateTime = TimeZoneInfo.ConvertTime(DateTime.Now, zone);
            int          result   = _reserveRepo.SetCode(codeUser.Id_reserve, codeUser.Code);

            if (result == 1)
            {
                Log.Information("Set code OK from mobile {id} done. {DateTime}.", codeUser.Id_reserve, dateTime);
                return(Ok(codeUser));
            }
            else if (result == 2)
            {
                Log.Information("Set code Code_is_duplicated from mobile {id} done. {DateTime}.", codeUser.Id_reserve, dateTime);
                return(NotFound("Code_is_duplicated"));
            }
            else
            {
                Log.Information("Set code Error to set code from mobile {id_reserve}. {DateTime}.", codeUser.Id_reserve, dateTime);
                return(NotFound("Error to set code"));
            }
        }
        public JsonResult ResetPassword(int id)
        {
            Message msg = new Message();

            CodeUser coder           = unitOfWork.codeUsersRepository.GetByID(id);
            string   password        = CommonTools.GenerateRandomNumber(8);
            string   confirmpassword = CommonTools.ToMd5(password);

            coder.Password = confirmpassword;



            if (ModelState.IsValid)
            {
                unitOfWork.codeUsersRepository.Update(coder);
                unitOfWork.Save();
                string EmailContent = "密码已经被重置为" + password.ToString() + ",请注意查收!";

                msg.MessageStatus = "true";
                msg.MessageInfo   = EmailContent;
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }