示例#1
0
        // GET: Admin/User
        public ActionResult Index(string searchString, int page = 1, int pageSize = 2)
        {
            var userController = new MoUserController();
            var model          = userController.ListAllPaging(searchString, page, pageSize);

            return(View(model));
        }
示例#2
0
        public ActionResult ChangePassword(int id)
        {
            var session = (UserLogin)Session[GamingShop.Common.CommonConstants.USER_SESSION];
            var model   = new MoUserController().GetById(session.UserName);

            return(View(model));
        }
示例#3
0
        public ActionResult ChangePassword(User user, string password, string newpassword, string confirmpassword)
        {
            var  session        = (UserLogin)Session[GamingShop.Common.CommonConstants.USER_SESSION];
            long id             = session.UserID;
            var  userController = new MoUserController();

            ViewBag.Success = false;
            if (user.Password == password)
            {
                if (newpassword == confirmpassword)
                {
                    var encryptednewpassword = Encryptor.MD5Hash(newpassword);
                    user.Password = encryptednewpassword;
                    var result = userController.ChangePassword(id, user);
                    if (result)
                    {
                        return(RedirectToAction("ChangePassword/" + session.UserID, "User"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Confirm password is wrong");
                }
            }
            else
            {
                ModelState.AddModelError("", "Change password not succeeded");
            }
            return(View("ChangePassword"));
        }
 public ActionResult NewPassword(string newpassword, string confirmpassword)
 {
     if (ModelState.IsValid)
     {
         var forgotpasswordsession = (ForgotPasswordModel)Session[GamingShop.Common.CommonConstants.ForgotPasswordSession];
         var userController        = new MoUserController();
         var user = userController.GetByMail(forgotpasswordsession.Email);
         if (newpassword == confirmpassword)
         {
             var encryptednewpassword = Encryptor.MD5Hash(newpassword);
             user.Password = encryptednewpassword;
             var result = userController.ChangePassword(user.ID, user);
             if (result)
             {
                 return(View("Success"));
             }
         }
         else
         {
             ModelState.AddModelError("", "Change password not succeeded");
             return(View("NewPassword"));
         }
     }
     return(View("Success"));
 }
示例#5
0
 public ActionResult Login(LoginModel model)
 {
     if (ModelState.IsValid)
     {
         var result = new MoUserController().Login(model.UserName, Encryptor.MD5Hash(model.Password));
         if (result == 1)
         {
             var user        = new MoUserController().GetById(model.UserName);
             var userSession = new UserLogin();
             userSession.UserName = user.UserName;
             userSession.UserID   = user.ID;
             Session.Add(CommonConstants.USER_SESSION, userSession);
             return(RedirectToAction("Index", "Home"));
         }
         else if (result == 0)
         {
             ModelState.AddModelError("", "Account does not exist.");
         }
         else if (result == -1)
         {
             ModelState.AddModelError("", "Account does not active.");
         }
         else if (result == -2)
         {
             ModelState.AddModelError("", "Wrong password.");
         }
     }
     return(View(model));
 }
示例#6
0
        public JsonResult ChangeStatus(long id)
        {
            var result = new MoUserController().ChangeStatus(id);

            return(Json(new
            {
                status = result
            }));
        }
示例#7
0
        public ActionResult Edit(User user)
        {
            var  session        = (UserLogin)Session[GamingShop.Common.CommonConstants.USER_SESSION];
            long id             = session.UserID;
            var  userController = new MoUserController();
            var  result         = userController.Edit(id, user);

            if (result)
            {
                return(RedirectToAction("Index", "User"));
            }
            else
            {
                ModelState.AddModelError("", "Update not succeeded");
            }
            return(View("Index"));
        }
示例#8
0
        public ActionResult Checkout(string shipName, string mobile, string address, string email)
        {
            var session        = (UserLogin)Session[GamingShop.Common.CommonConstants.USER_SESSION];
            var userController = new MoUserController();
            var order          = new Order();

            if (session != null)
            {
                var user = userController.GetById(session.UserName);
                order.ID          = user.ID;
                order.CreatedDate = DateTime.Now;
                order.ShipAddress = user.Address;
                order.ShipName    = user.Name;
                order.ShipEmail   = user.Email;
                order.ShipMobile  = user.Phone;
            }
            else
            {
                order.CreatedDate = DateTime.Now;
                order.ShipAddress = address;
                order.ShipName    = shipName;
                order.ShipEmail   = email;
                order.ShipMobile  = mobile;
            }
            try
            {
                var id     = new MoOrderController().Insert(order);
                var cart   = (List <CartItem>)Session[CartSession];
                var detail = new MoOrderDetailController();

                foreach (var item in cart)
                {
                    var orderDetail = new OrderDetail();
                    orderDetail.ProductID = item.Product.ID;
                    orderDetail.OrderID   = id;
                    orderDetail.Price     = item.Product.Price;
                    orderDetail.Quantity  = item.Quantity;
                    detail.Insert(orderDetail);
                }
            }
            catch (Exception ex)
            {
                return(Redirect("/CheckoutError"));
            }
            return(RedirectToAction("Success"));
        }
        public ActionResult ForgotPassword(string email)
        {
            var user = new MoUserController().CheckEmail(email);

            if (!user)
            {
                ModelState.AddModelError("", "Email is not valid.");
            }
            Random random         = new Random();
            var    forgotpassword = new ForgotPasswordModel();

            forgotpassword.Code  = random.Next(100000, 999999).ToString();
            forgotpassword.Email = email;
            Session.Add(CommonConstants.ForgotPasswordSession, forgotpassword);
            SendConfirmMail(email, forgotpassword.Code);
            return(View("ConfirmCode"));
        }
示例#10
0
        public ActionResult Checkout()
        {
            var cart    = Session[CartSession];
            var list    = new List <CartItem>();
            var session = (UserLogin)Session[GamingShop.Common.CommonConstants.USER_SESSION];

            if (session != null)
            {
                var userController = new MoUserController();
                var user           = userController.GetById(session.UserName);
                ViewBag.User = user;
            }
            if (cart != null)
            {
                list = (List <CartItem>)cart;
            }
            return(View(list));
        }
示例#11
0
 public ActionResult Create(User user)
 {
     if (ModelState.IsValid)
     {
         var userController  = new MoUserController();
         var encryptedMd5Pas = Encryptor.MD5Hash(user.Password);
         user.Password = encryptedMd5Pas;
         user.GroupID  = "admin";
         long id = userController.Insert(user);
         if (id > 0)
         {
             SetAlert("Thêm user thành công", "success");
             return(RedirectToAction("Index", "User"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm user không thành công");
         }
     }
     return(View("Index"));
 }
示例#12
0
 public ActionResult Register(RegisterModel model)
 {
     if (ModelState.IsValid)
     {
         var userController = new MoUserController();
         if (userController.CheckUserName(model.UserName))
         {
             ModelState.AddModelError("", "Invalid user name");
         }
         else if (userController.CheckEmail(model.Email))
         {
             ModelState.AddModelError("", "Email has already been registed");
         }
         else
         {
             var user = new User();
             user.Name        = model.Name;
             user.Password    = Encryptor.MD5Hash(model.Password);
             user.Phone       = model.Phone;
             user.Address     = model.Address;
             user.Email       = model.Email;
             user.CreatedDate = DateTime.Now;
             user.Status      = true;
             user.GroupID     = "customer";
             var result = userController.Insert(user);
             if (result > 0)
             {
                 ViewBag.Success = "Registerd Success";
                 model           = new RegisterModel();
             }
             else
             {
                 ModelState.AddModelError("", "Error occur");
             }
         }
     }
     return(View(model));
 }
示例#13
0
        public ActionResult Edit(User user)
        {
            var userController = new MoUserController();

            if (!string.IsNullOrEmpty(user.Password))
            {
                var encryptedMD5Pass = Encryptor.MD5Hash(user.Password);
                user.Password = encryptedMD5Pass;
            }

            var result = userController.Update(user);

            if (result)
            {
                SetAlert("Sửa user thành công", "success");
                return(RedirectToAction("Index", "User"));
            }
            else
            {
                ModelState.AddModelError("", "Update not succeeded");
            }
            return(View("Index"));
        }
示例#14
0
        // GET: Admin/User/Edit/5
        public ActionResult Edit(int id)
        {
            var user = new MoUserController().ViewDetail(id);

            return(View(user));
        }