Пример #1
0
        public ActionResult ResetPasswordUser(int?userID)
        {
            if (!userID.HasValue)
            {
                return(View("Error"));
            }
            else
            {
                using (var db = new WebDauGiaEntities())
                {
                    var user = db.Users.Find(userID);
                    // gửi pasword mới cho user
                    var newPWD = StringUtils.RandomString(6);
                    var body   = new StringBuilder();
                    body.Append($"<h3>Chào {user.Name} !</h2>");
                    body.Append($"<h1 style='color:blue;'>Password của bạn đã được reset.</h1>");
                    body.Append($"<h3 >Password mới của bạn là: <span style='color:red;'>{newPWD}<span></h3>");

                    Email.Send(user.Email, "[Thế Giới Ngầm] Reset password.", body);

                    user.Password = StringUtils.Md5(newPWD);
                    db.SaveChanges();

                    string notify = "Reset password thành công . Password mới đã được gửi vào email của User!";

                    return(RedirectToAction("ManageUser", new { message = notify }));
                }
            }
        }
Пример #2
0
 public ActionResult DangKy(ThanhVien model)
 {
     if (!ModelState.IsValid)
     {
         // TODO: Captcha validation failed, show error message
         ViewBag.ErrorMsg = "Bạn nhập sai Captcha!";
         return(View());
     }
     else
     {
         // TODO: Captcha validation passed, proceed with protected action
         ThanhVien m = new ThanhVien
         {
             TenDangNhap = model.TenDangNhap,
             MatKhau     = StringUtils.Md5(model.MatKhau),
             Email       = model.Email,
             HoTen       = model.HoTen,
             DiaChi      = model.DiaChi
         };
         using (WebDauGiaEntities ctx = new WebDauGiaEntities())
         {
             ctx.ThanhViens.Add(m);
             ctx.SaveChanges();
         }
         return(RedirectToAction("DangNhap", "User"));
     }
 }
Пример #3
0
        public ActionResult Approve(int productID, int vendorID)
        {
            using (var db = new WebDauGiaEntities())
            {
                var pro = db.Products.Find(productID);
                pro.Status  = 1;
                pro.DateEnd = DateTime.Now.AddDays(7);
                db.SaveChanges();
                //khởi tạo nội dung mail
                var user  = db.Users.Find(vendorID);
                var image = db.Photos.Where(p => p.ProductID == productID).FirstOrDefault().Name;
                image = image.Substring(2).Trim();
                var body = new StringBuilder();
                body.Append($"<h3>Chào {user.Name} !</h2>");
                body.Append($"<h1 style='color:blue'>Chúc mừng bạn của bạn đăng đã được duyệt.</h1>");
                body.Append($"<h1 style='color:blue'>Sản phẩm {pro.Name}</h1>");
                body.Append($"<img style='width:300px;height:400px;' src=cid:MyPic>");
                body.Append($"<h3 style='color:green;'>Ngày đăng của sản phẩm: {pro.DateStart}$</h3>");
                body.Append($"<h3>Sản phẩm sẽ được đăng trong vòng 7 ngày kể từ ngày được duyệt.</h3>");
                body.Append($"<h3>Thời gian kết thúc đấu giá của sản phẩm là: <span style='color:red;'>{pro.DateEnd}</span></h3>");
                body.Append($"<h3>Bạn có thể xem chi tiết sản phẩm <a href='http://localhost:62902/Product/Detail?productID={pro.ID}'>tại đây.</a></h3>");
                LinkedResource yourPictureRes = new LinkedResource(Path.Combine(HttpRuntime.AppDomainAppPath, image));
                yourPictureRes.ContentId = "MyPic";
                Email.Send(user.Email, "[Thế Giới Ngầm] Chúc mừng bạn sản phẩm đã được duyệt.", body, yourPictureRes);

                string notify = "Duyệt sản phẩm thành công !";
                return(RedirectToAction("Approve", "Admin", new { message = notify }));
            }
        }
Пример #4
0
 public ActionResult EditCategory(Category item)
 {
     using (var db = new WebDauGiaEntities())
     {
         var cate = db.Categories.Find(item.ID);
         cate.Name = item.Name;
         db.SaveChanges();
         ViewBag.Success = "Chỉnh sửa tên thể loại thành công !";
         return(View(cate));
     }
 }
Пример #5
0
 public ActionResult RemoveCategory(int id)
 {
     using (var db = new WebDauGiaEntities())
     {
         var cate = db.Categories.Find(id);
         cate.Status = false;
         db.SaveChanges();
         string notify = "Đã xóa thể loại thành công !";
         return(RedirectToAction("ManageCategory", new { message = notify }));
     }
 }
Пример #6
0
        public ActionResult AddCategory(Category item)
        {
            using (var db = new WebDauGiaEntities())
            {
                item.Status = true;
                db.Categories.Add(item);
                db.SaveChanges();
                string spDirPath     = Server.MapPath("~/images/products");
                string targetDirpath = Path.Combine(spDirPath, item.ID.ToString());
                Directory.CreateDirectory(targetDirpath);

                string notify = "Đã thêm thể loại thành công !";
                return(RedirectToAction("ManageCategory", new { message = notify }));
            }
        }
Пример #7
0
 public ActionResult Edit(EditProductViewModel model)
 {
     using (var db = new WebDauGiaEntities())
     {
         var pro = db.Products.Find(model.ProductID);
         pro.Descrition = pro.Descrition + "<br>" + model.Des;
         db.SaveChanges();
         ViewBag.MsgSuccess = "Chỉnh sửa thông tin sản phẩm thành công !";
         var list = (from p in db.Products
                     join v in db.Users on p.VendorID equals v.ID
                     join w in db.Users on p.Winner equals w.ID
                     where p.ID == model.ProductID
                     select new ProductDetailViewModel
         {
             ID = p.ID,
             Name = p.Name,
             VendorID = v.ID,
             VendorName = v.Name.Trim(),
             VendorImage = v.Photo,
             Price = p.Price,
             Description = p.Descrition,
             DateStart = p.DateStart,
             DateEnd = p.DateEnd,
             PriceAuction = p.PriceAuction,
             WinnerID = w.ID,
             WinnerName = w.Name.Trim(),
             StepPrice = p.StepPrice,
             BuyNowPice = p.BuyNowPice,
             Status = p.Status,
             FeedbackVendor = (int)(((double)(v.Positive + v.Negative + 1) / (v.Positive + 1)) * 100),
             FeedbackWinner = (int)(((double)(w.Positive + w.Negative + 1) / (w.Positive + 1)) * 100),
         }).FirstOrDefault();
         var listUser = (from h in db.HistoryAuctions
                         join u in db.Users on h.UserID equals u.ID
                         where h.ProductID == model.ProductID && h.Denied == 0
                         select new HistoryAuctionProductVM
         {
             UserID = h.UserID,
             UserName = u.Name,
             DateAction = h.DateAction
         }).ToList();
         ViewBag.History = listUser.ToList();
         return(View(list));
     }
 }
Пример #8
0
        public ActionResult RemoveUser(int?userID)
        {
            if (!userID.HasValue)
            {
                return(View("Error"));
            }
            using (var db = new WebDauGiaEntities())
            {
                var user = db.Users.Find(userID);
                user.Status = 0;
                db.SaveChanges();

                var body = new StringBuilder();
                body.Append($"<h3>Chào {user.Name} !</h2>");
                body.Append($"<h1 style='color:red;'>Cảnh báo tài khoản của bạn đã bị xóa.</h1>");
                body.Append($"<h3 style='color:red;'>Vì một số lý do tài khoản của bạn đã bị xóa.</h3>");
                Email.Send(user.Email, "[Thế Giới Ngầm] Cảnh báo tài khoản của bạn đã bị xóa.", body);
                string notify = "Đã xóa user thành công !";

                return(RedirectToAction("ManageUser", new { message = notify }));
            }
        }
Пример #9
0
        public ActionResult ApproveSale(int userID)
        {
            using (var db = new WebDauGiaEntities())
            {
                var user = db.Users.Find(userID);
                user.SaleStatus    = 0;
                user.DateStartSale = DateTime.Now;
                user.DateEndSale   = DateTime.Now.AddDays(7);
                db.SaveChanges();
                string notify = "Đã duyệt thành công !";
                // khởi tạo nội dung mail
                var body = new StringBuilder();
                body.Append($"<h3>Chào {user.Name} !</h2>");
                body.Append($"<h1 style='color:blue'>Chúc mừng bạn đã trở thành người bán hàng.</h1>");

                body.Append($"<h3>Bạn sẽ được đăng sản phẩm trong vòng 7 ngày kể từ ngày được duyệt.</h3>");
                body.Append($"<h3>Thời gian bắt đầu: <span style='color:red;'>{user.DateEndSale}</span></h3>");
                body.Append($"<h3>Thời gian kết thúc: <span style='color:red;'>{user.DateEndSale}</span></h3>");

                Email.Send(user.Email, "[Thế Giới Ngầm] Chúc mừng bạn đã trở thành người bán hàng.", body);
                return(RedirectToAction("ApproveSale", "Admin", new { message = notify }));
            }
        }