public ActionResult EditProfile([Bind(Include = "id,email,password,fullname,phone,gender,dayOfBirth,address,avatar,dateStart,dateEnd,contractSalary,unitSalary,workTime,schedule,createdDate,createdBy,modifyDate,modifyBy,status,activated")] Employee employee,
                                        HttpPostedFileBase avatar, string roleEmployee)
        {
            LAUNDRY_PROJECTEntities db = new LAUNDRY_PROJECTEntities();

            if (ModelState.IsValid)
            {
                string path = Server.MapPath("/Assets/Admin/resources/image");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                if (employee.avatar != null)
                {
                    avatar.SaveAs(path + "/" + avatar.FileName);
                    employee.avatar = "Assets/Admin/resources/image/" + avatar.FileName;
                }
                else
                {
                    employee.avatar = "Assets/Admin/resources/image/" + "userDefault.jpg";
                }

                AccountRole account = new AccountRole();
                account.employeeId  = employee.id;
                account.roleId      = Int32.Parse(roleEmployee);
                employee.modifyDate = DateTime.Now;
                employee.modifyBy   = Session["username_Employee"].ToString();
                long idEmployee = employee.id;
                db.AccountRoles.Add(account);
                db.Entry(employee).State = EntityState.Modified;
                db.SaveChanges();
                return(new RedirectResult(url: "/Admin/Account/infoProfile/" + idEmployee + "?message=update_success"));
            }
            return(View(employee));
        }
 public ActionResult Login(string email, string password)
 {
     if (email != null && password != null)
     {
         using (LAUNDRY_PROJECTEntities db = new LAUNDRY_PROJECTEntities())
         {
             var account = db.Employees.Where(x => x.email.Equals(email)).SingleOrDefault();
             if (account != null)
             {
                 var passwordCheck = account.password.Equals(EncryptPassword.EncryptForPassword(password));
                 if (passwordCheck)
                 {
                     Session["username_Employee"] = account.fullname;
                     Session["email_Employee"]    = account.email;
                     Session["password_Employee"] = EncryptPassword.DecryptPassword(account.password);
                     Session["id_Employee"]       = account.id;
                     Session["image_Employee"]    = account.avatar;
                     FormsAuthentication.SetAuthCookie(email, false);
                     return(RedirectToAction("Index", "DashBoard"));
                 }
                 else
                 {
                     return(new RedirectResult(url: "/Admin/Account/Login?message=invalid_password"));
                 }
             }
             else
             {
                 return(new RedirectResult(url: "/Admin/Account/Login?message=invalid_email"));
             }
         }
     }
     return(RedirectToAction("Index", "DashBoard"));
 }
Пример #3
0
        public ActionResult EditProfile([Bind(Include = "id,email,password,fullname,phone,gender,dayOfBirth,address,avatar,idCounty,activated,status,createdDate,modifyDate,modifyBy,roleId")] Customer customer,
                                        HttpPostedFileBase avatar)
        {
            LAUNDRY_PROJECTEntities db = new LAUNDRY_PROJECTEntities();

            if (ModelState.IsValid)
            {
                string path = Server.MapPath("/Assets/Client/resources/image");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                if (customer.avatar != null)
                {
                    avatar.SaveAs(path + "/" + avatar.FileName);
                    customer.avatar = "Assets/Client/resources/image/" + avatar.FileName;
                }
                else
                {
                    customer.avatar = "Assets/Client/resources/image/" + "customerDefault.jpg";
                }

                customer.modifyDate      = DateTime.Now;
                customer.modifyBy        = Session["username_Customer"].ToString();
                db.Entry(customer).State = EntityState.Modified;
                db.SaveChanges();
                return(new RedirectResult(url: "/Account/infoProfile/" + customer.id + "?message=update_success"));
            }
            ViewBag.idCounty = new SelectList(db.Counties, "id", "name", customer.idCounty);
            return(View(customer));
        }
Пример #4
0
        public ActionResult DetailOrder(long?id)
        {
            LAUNDRY_PROJECTEntities db = new LAUNDRY_PROJECTEntities();
            List <OrderDetail>      listOrderDetail = db.OrderDetails.Where(o => o.orderId == id).ToList();

            ViewBag.OrderDetail = listOrderDetail;
            return(View());
        }
Пример #5
0
        public ActionResult orderList(int?id)
        {
            LAUNDRY_PROJECTEntities db    = new LAUNDRY_PROJECTEntities();
            List <Order>            order = db.Orders.Where(o => o.customerId == id).OrderByDescending(o => o.orderDate).ToList();

            ViewBag.OrderList = order;
            return(View());
        }
        public JsonResult changePassword(long id, string newPass)
        {
            LAUNDRY_PROJECTEntities db = new LAUNDRY_PROJECTEntities();
            Employee employee          = db.Employees.Where(x => x.id == id).FirstOrDefault();

            employee.password = EncryptPassword.EncryptForPassword(newPass);
            db.SaveChanges();
            return(Json(1, JsonRequestBehavior.AllowGet));
        }
Пример #7
0
        // nhận xác nhân email
        public ActionResult ActiveEmail(string username)
        {
            LAUNDRY_PROJECTEntities db = new LAUNDRY_PROJECTEntities();
            Customer customer          = db.Customers.Where(c => c.email.Equals(username)).SingleOrDefault();

            if (customer != null)
            {
                customer.activated = true;
                db.SaveChanges();
                return(new RedirectResult(url: "/Account/Login?message=insert_success"));
            }
            return(View(customer));
        }
Пример #8
0
        public ActionResult infoProfile(int?id)
        {
            LAUNDRY_PROJECTEntities db = new LAUNDRY_PROJECTEntities();
            string message             = Request.QueryString["message"];

            if (message != null)
            {
                Dictionary <string, string> viewData = MessageUtil.getMessage(message);
                ViewData["message"] = viewData["message"];
                ViewData["alert"]   = viewData["alert"];
            }
            Customer customer = db.Customers.Where(x => x.id == id).SingleOrDefault();

            ViewBag.idCounty = new SelectList(db.Counties, "id", "name");
            return(View(customer));
        }
Пример #9
0
        public ActionResult RegisterAccount(FormCollection form)
        {
            LAUNDRY_PROJECTEntities db = new LAUNDRY_PROJECTEntities();
            string email           = Request.Form["email"];
            string password        = Request.Form["password"];
            string confirmPassword = Request.Form["confirmPassword"];

            var checkEmail = db.Customers.Where(c => c.email.Equals(email)).FirstOrDefault();

            if (checkEmail != null)
            {
                return(new RedirectResult(url: "/Account/RegisterAccount?message=email_exists"));
            }
            else
            {
                if (!password.Equals(confirmPassword))
                {
                    return(new RedirectResult(url: "/Account/RegisterAccount?message=invalid_password"));
                }
                else
                {
                    Customer customer = new Customer();
                    customer.email       = email;
                    customer.password    = EncryptPassword.EncryptForPassword(password);
                    customer.fullname    = "";
                    customer.address     = "";
                    customer.idCounty    = 1;
                    customer.avatar      = "Assets/Client/resources/image/" + "customerDefault.jpg";
                    customer.activated   = false;
                    customer.status      = true;
                    customer.createdDate = DateTime.Now;
                    customer.modifyDate  = DateTime.Now;
                    customer.dayOfBirth  = DateTime.Now;
                    customer.modifyBy    = "";
                    customer.roleId      = 3;

                    db.Customers.Add(customer);
                    db.SaveChanges();

                    SendEmail.SendMail("Gửi từ Laundry Store, Xác nhận người dùng ! ", customer.email, " Bạn vừa đăng kí thành công tài khoản tại Laundry Store !" +
                                       " Với tên đăng nhập : " + customer.email +
                                       " Để kích hoạt tài khoản vừa đăng kí, vui lòng xác nhận tại đường dẫn tại đây: " + "https://localhost:44335/Account/ActiveEmail/?username="******"/Account/RegisterAccount?message=confirm_email"));
                }
            }
        }
Пример #10
0
 public CartItem(long productId)
 {
     using (LAUNDRY_PROJECTEntities db = new LAUNDRY_PROJECTEntities())
     {
         this.productId = productId;
         Product product = db.Products.Single(p => p.id == productId);
         this.image       = product.image;
         this.productName = product.productName;
         this.description = product.description;
         this.quantity    = 1;
         this.price       = product.price;
         this.discount    = product.discount;
         this.type        = product.type;
         int?amount = price * quantity;
         this.total = amount * (100 - discount) / 100;
     }
 }
        public ActionResult forgotPassword(FormCollection form)
        {
            LAUNDRY_PROJECTEntities db = new LAUNDRY_PROJECTEntities();
            string   email             = Request.Form["email"];
            Employee employee          = db.Employees.Where(x => x.email.Equals(email)).FirstOrDefault();

            if (employee == null)
            {
                return(new RedirectResult(url: "/Admin/Account/forgotPassword?message=invalid_email"));
            }
            else
            {
                string password = EncryptPassword.DecryptPassword(employee.password);
                SendEmail.SendMail("Gửi từ Laundry Store, Xác nhận người dùng ! ", employee.email, " lấy lại mật khẩu !" +
                                   " Với tên đăng nhập : " + employee.email +
                                   " Mật khẩu của bạn là: " + password + ", click đường dẫn dưới đây để quay về trang đăng nhập " + "https://localhost:44335/Admin/Account/Login");
                return(new RedirectResult(url: "/Admin/Account/Login?message=confirm_email"));
            }
        }
Пример #12
0
        public ActionResult LoginToComment(string email, string password)
        {
            string idPost = Request.Form["idPost"];

            if (email != null && password != null)
            {
                using (LAUNDRY_PROJECTEntities db = new LAUNDRY_PROJECTEntities())
                {
                    var account = db.Customers.Where(x => x.email.Equals(email) && x.status == true && x.activated == true).FirstOrDefault();
                    if (account != null)
                    {
                        if (account.activated == true)
                        {
                            var passwordCheck = account.password.Equals(EncryptPassword.EncryptForPassword(password));
                            if (passwordCheck)
                            {
                                Session["username_Customer"] = account.fullname;
                                Session["email_Customer"]    = account.email;
                                Session["password_Customer"] = account.password;
                                Session["id_Customer"]       = account.id;
                                Session["image_Customer"]    = account.avatar;
                                FormsAuthentication.SetAuthCookie(email, false);
                                return(new RedirectResult(url: "/Blogs/Details/" + idPost + "?message=login_sucess"));
                            }
                            else
                            {
                                return(new RedirectResult(url: "/Blogs/Details/" + idPost + "?message=invalid_password"));
                            }
                        }
                        else
                        {
                            return(new RedirectResult(url: "/Blogs/Details/" + idPost + "?message=authentication_email"));
                        }
                    }
                    else
                    {
                        return(new RedirectResult(url: "/Blogs/Details/" + idPost + "?message=invalid_email"));
                    }
                }
            }
            return(new RedirectResult(url: "/Blogs/Details/" + idPost));
        }
Пример #13
0
 public ActionResult Login(string email, string password)
 {
     if (email != null && password != null)
     {
         using (LAUNDRY_PROJECTEntities db = new LAUNDRY_PROJECTEntities())
         {
             var account = db.Customers.Where(x => x.email.Equals(email) && x.status == true && x.activated == true).FirstOrDefault();
             if (account != null)
             {
                 if (account.activated == true)
                 {
                     var passwordCheck = account.password.Equals(EncryptPassword.EncryptForPassword(password));
                     if (passwordCheck)
                     {
                         Session["username_Customer"] = account.fullname;
                         Session["email_Customer"]    = account.email;
                         Session["password_Customer"] = EncryptPassword.DecryptPassword(account.password);
                         Session["id_Customer"]       = account.id;
                         Session["image_Customer"]    = account.avatar;
                         FormsAuthentication.SetAuthCookie(email, false);
                         return(RedirectToAction("Index", "Home"));
                     }
                     else
                     {
                         return(new RedirectResult(url: "/Account/Login?message=invalid_password"));
                     }
                 }
                 else
                 {
                     return(new RedirectResult(url: "/Account/Login?message=authentication_email"));
                 }
             }
             else
             {
                 return(new RedirectResult(url: "/Account/Login?message=invalid_email"));
             }
         }
     }
     return(View());
 }
        public ActionResult infoProfile(int?id)
        {
            LAUNDRY_PROJECTEntities db = new LAUNDRY_PROJECTEntities();
            string message             = Request.QueryString["message"];

            if (message != null)
            {
                Dictionary <string, string> viewData = MessageUtil.getMessage(message);
                ViewData["message"] = viewData["message"];
                ViewData["alert"]   = viewData["alert"];
            }
            Employee           employee    = db.Employees.Where(x => x.id == id).SingleOrDefault();
            List <AccountRole> listAccount = db.AccountRoles.Where(x => x.employeeId == employee.id).ToList();

            int[] arrayRole = new int[listAccount.Count];
            for (int i = 0; i < listAccount.Count; i++)
            {
                arrayRole[i] = listAccount[i].Role.id;
            }
            ViewBag.RoleEmployee     = arrayRole[0];
            ViewBag.PasswordEmployee = Session["password_Employee"];
            ViewBag.IdEmployee       = Session["id_Employee"];
            return(View(employee));
        }