// GET huong dan thanh toan
        public ActionResult HuongDanThanhToan()
        {
            var db = new ShopOnlineDb();
            var huongdanthanhtoan = db.AboutShops.Where(x => x.Title.Contains("Hướng dẫn thanh toán")).ToList();

            return(View(huongdanthanhtoan));
        }
        // Get about shop article
        public ActionResult IntroduceStore()
        {
            var db = new ShopOnlineDb();
            var aboutShopArticle = db.AboutShops.Where(x => x.Title.Contains("Giới thiệu cửa hàng")).ToList();

            return(View(aboutShopArticle));
        }
Ejemplo n.º 3
0
        public ActionResult ChuyenXuLyDonHang(string OrderGuid, int?UserId, string OrderName)
        {
            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        shOrderService _order = new shOrderService();
                        shOrder        order  = _order.ChuyenXuLyDonhang(OrderGuid, UserId, OrderName, User.Identity.GetUserLogin().Userid);

                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }


            if (Request.IsAjaxRequest())
            {
                return(Json("OK", JsonRequestBehavior.AllowGet));
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
        public ActionResult DeleteComment(string CommentGuid)
        {
            shCommentService _comment = new shCommentService();


            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(CommentGuid) || !string.IsNullOrWhiteSpace(CommentGuid))
                        {
                            shComment comment = _comment.FindByKey(CommentGuid);
                            comment.Status = false;
                            _comment.Update(comment);
                        }

                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        public ActionResult AddToCart(int ProductId, decimal Quantity)
        {
            using (var db = new ShopOnlineDb())
            {
                // TÌM PRODUCT THEO ProductId
                var product = db.Products.Find(ProductId);
                if (product != null)
                {
                    // XE HÀNG
                    var shoppingCart = new ShoppingCart();
                    if (Session["ShoppingCart"] != null)
                    {
                        shoppingCart = (ShoppingCart)Session["ShoppingCart"];
                    }

                    shoppingCart.AddToCart(product, Quantity);

                    Session["ShoppingCart"] = shoppingCart;

                    return(RedirectToAction("CheckOut", "ShoppingCart"));
                }

                return(HttpNotFound());
            }
        }
        // GET chinh sach doi tra hang
        public ActionResult ChinhSachDoiTra()
        {
            var db = new ShopOnlineDb();
            var chinhsachdoitra = db.AboutShops.Where(x => x.Title.Contains("Chính sách đổi trả")).ToList();

            return(View(chinhsachdoitra));
        }
        // GET huong dan mua hang
        public ActionResult HuongDanMuaHang()
        {
            var db = new ShopOnlineDb();
            var huongdanmuahang = db.AboutShops.Where(x => x.Title.Contains("Hướng dẫn mua hàng")).ToList();

            return(View(huongdanmuahang));
        }
Ejemplo n.º 8
0
        public ActionResult Xuat(string ReceiptIsuueGuid, string SizeAdd, int?TrangThai, int?LoaiPhieu, int?Kho, string GhiChu, string ReceiptIsuueName)
        {
            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        Kho = 2;

                        shGoodReceiptIsuueService _receipt = new shGoodReceiptIsuueService();
                        _receipt.XuatDuLieuKhoHang(
                            ReceiptIsuueGuid,
                            SizeAdd,
                            TrangThai,
                            LoaiPhieu,
                            Kho,
                            GhiChu,
                            User.Identity.GetUserLogin().Userid,
                            PhieuNhapXuat.Xuat.GetHashCode(),
                            ReceiptIsuueName,
                            true,
                            DateTime.Now
                            );

                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
        // GET chinh sach doi ưu đãi
        public ActionResult ChinhSachUuDai()
        {
            var db             = new ShopOnlineDb();
            var chinhsachuudai = db.AboutShops.Where(x => x.Title.Contains("Chính sách ưu đãi")).ToList();

            return(View(chinhsachuudai));
        }
Ejemplo n.º 10
0
        public ActionResult DeleteSection(string SectionGuid, string ProductGuid)
        {
            shSectionService _section = new shSectionService();
            shProductSet     section  = _section.FindByKey(SectionGuid);

            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        if (section != null)
                        {
                            section.Status = false;
                            _section.Update(section);
                        }

                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }


            if (Request.IsAjaxRequest())
            {
                return(Json("OK", JsonRequestBehavior.AllowGet));
            }

            return(RedirectToAction("Index"));
        }
 public ActionResult Search(string SearchText)
 {
     using (var db = new ShopOnlineDb())
     {
         var products = db.Products.Include(p => p.Category).Where(x => x.Name.Contains(SearchText) || x.DisplayPosition.Contains(SearchText)).ToList();
         return(View("Index", products));
     }
 }
 //Search order
 public ActionResult Search(string SearchText)
 {
     using (var db = new ShopOnlineDb())
     {
         var orders = db.Orders.Where(x => x.ContactName.Contains(SearchText) || x.ContactPhone.Contains(SearchText)).ToList();
         return(View("Index", orders));
     }
 }
 public ActionResult Index()
 {
     using (var db = new ShopOnlineDb())
     {
         var products = db.Products.ToList();
         return(View(products));
     }
 }
        public ActionResult Search(string SearchText)
        {
            using (var db = new ShopOnlineDb())
            {
                var products = db.Products.Where(x => x.Name.Contains(SearchText)).ToList();

                return(View(products));
            }
        }
Ejemplo n.º 15
0
        public ActionResult Create(string DanhMucGuid, int?DanhMucId, string CategoryName, string CategoryGuid, bool?Status, string Description, int?SortOrder, string FileName)
        {
            shCategory category = new shCategory();

            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        // Insert- update Category
                        shCategoryService _category = new shCategoryService();
                        category = _category.ThemMoi_HieuChinhCategory(
                            DanhMucGuid,
                            null,
                            CategoryName,
                            CategoryGuid,
                            null,
                            Status,
                            DateTime.Now,
                            null,
                            Description,
                            SortOrder,
                            FileName);

                        // Insesrt Image
                        if (!string.IsNullOrEmpty(FileName) || !string.IsNullOrWhiteSpace(FileName))
                        {
                            shCategoryImageService _categoryImage = new shCategoryImageService();
                            shCategoryImage        categoryImage  = _categoryImage.Insert_UpdateCategoryImage(
                                null,
                                null,
                                category.CategoryGuid,
                                FileName,
                                null,
                                User.Identity.GetUserLogin().Userid,
                                true,
                                DateTime.Now,
                                null
                                );
                        }

                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }

            int?page = CommonHelper.FindPageCategory(category.CategoryGuid, category.CategoryId);

            return(RedirectToAction("Index", new { page = page }));
        }
        // GET: NiceFood
        public ActionResult Index(int?page)
        {
            using (var db = new ShopOnlineDb())
            {
                var nicheInformation = db.NicheInformations.ToList();
                int pageSize         = 6;
                int pageNumber       = (page ?? 1);

                return(View(nicheInformation.ToPagedList(pageNumber, pageSize)));
            }
        }
        public ActionResult DisplayByCategory(int categoryId, int?page)
        {
            using (var db = new ShopOnlineDb())
            {
                var products = db.Products.Where(x => x.CategoryId == categoryId).ToList();

                int pageSize   = 9;
                int pageNumber = (page ?? 1);

                return(View("index", products.ToPagedList(pageNumber, pageSize)));
            }
        }
        // GET: Product
        public ActionResult SanphamnoibatList(int?page)
        {
            using (var db = new ShopOnlineDb())
            {
                var products = db.Products.Where(x => x.Status == "ACTIVE" && x.DisplayPosition == "SAN PHAM NOI BAT").OrderBy(x => x.SortOrder).ToList();

                int pageSize   = 6;
                int pageNumber = (page ?? 1);

                return(View(products.ToPagedList(pageNumber, pageSize)));
            }
        }
Ejemplo n.º 19
0
        public ActionResult TopSanPham(string StartTime, string EndTime, string TheLoai)
        {
            DateTime _tungay = DateTime.Now;

            if (!string.IsNullOrEmpty(StartTime) || !string.IsNullOrWhiteSpace(StartTime))
            {
                _tungay = TypeHelper.ToDate(StartTime);
            }

            DateTime _denngay = DateTime.Now;

            if (!string.IsNullOrEmpty(EndTime) || !string.IsNullOrWhiteSpace(EndTime))
            {
                _denngay = TypeHelper.ToDate(EndTime);
            }

            List <BieuDoTop>     dsBieuDo     = new List <BieuDoTop>();
            BieuDoTop            top          = new BieuDoTop();
            shOrderDetailService _orderDetail = new shOrderDetailService();
            shProductService     _product     = new shProductService();
            ShopOnlineDb         db           = new ShopOnlineDb();

            IEnumerable <shOrderDetail> dsOrderDetail = _orderDetail.DanhSachOrderDetail_TheoThoiGian(_tungay, _denngay);
            int TongSoLuong = TinhTongSoLuong(dsOrderDetail);
            IEnumerable <string> dsDistinct = dsOrderDetail.Select(x => x.ProductGuid).Distinct();

            foreach (var item in dsDistinct)
            {
                IEnumerable <shOrderDetail> dsTheoSanPham = dsOrderDetail.Where(x => x.ProductGuid == item);
                top       = new BieuDoTop();
                top.label = _product.ProductName(item);
                top.y     = TinhTongSoLuong(dsTheoSanPham);

                if (TheLoai == Config.SoLuong)
                {
                    top.indexLabel = top.y.ToString();
                }
                else if (TheLoai == Config.DoanhThu)
                {
                    top.indexLabel = Format.FormatDecimalToString(TinhTongSoTien(dsTheoSanPham));
                }

                dsBieuDo.Add(top);
            }

            dsBieuDo = dsBieuDo.OrderBy(x => x.y).Take(Config.Top_10).ToList();

            if (Request.IsAjaxRequest())
            {
                return(Json(dsBieuDo, JsonRequestBehavior.AllowGet));
            }
            return(PartialView("TopSanPhamTheoSoLuong"));
        }
        // GET: Product
        public ActionResult ListStyleIndex(int?page)
        {
            using (var db = new ShopOnlineDb())
            {
                var products = db.Products.ToList();

                int pageSize   = 9;
                int pageNumber = (page ?? 1);

                return(View(products.ToPagedList(pageNumber, pageSize)));
            }
        }
Ejemplo n.º 21
0
        public ActionResult EditSize(string SizeGuid, string ProductGuid, string SectionGuid, string SizeName, decimal?PriceCurrent, string Stuff, string Parent)
        {
            shSizeService _size = new shSizeService();
            shSetSize     size  = new shSetSize();

            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        size = _size.InsertUpdateSize(
                            SizeGuid,
                            null,
                            ProductGuid,
                            SectionGuid,
                            SizeName,
                            null,
                            PriceCurrent,
                            null,
                            null,
                            null,
                            null,
                            null,
                            true,
                            DateTime.Now,
                            Stuff,
                            Parent);

                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }


            if (Request.IsAjaxRequest())
            {
                string data = "fail";
                if (size.SizeId > 0)
                {
                    data = "ok";
                }

                return(Json(data, JsonRequestBehavior.AllowGet));
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 22
0
        public ActionResult OrderProcessing(string OrderGuid, int?OrderStatus, string Description)
        {
            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        shGoodReceiptIsuueService _receipt = new shGoodReceiptIsuueService();
                        if (OrderStatus.HasValue)
                        {
                            if (OrderStatus == C.Core.Common.OrderStatus.DangGiaoHang.GetHashCode())
                            {
                                shOrderService _order = new shOrderService();
                                shOrder        order  = _order.XuLyDonhang(OrderGuid, null, User.Identity.GetUserLogin().Userid);
                            }
                            else
                            {
                                shGoodReceiptIsuue receipt = _receipt.XuatDuLieuDonHang(
                                    OrderGuid,
                                    OrderStatus,
                                    Description,
                                    User.Identity.GetUserLogin().Userid,
                                    PhieuNhapXuat.Xuat.GetHashCode(),
                                    TypeHelper.ToInt32(User.Identity.GetUserLogin().Unitid),
                                    LoaiPhieuNhapXuat.BanLe.GetHashCode(),
                                    Description,
                                    TrangThaiPhieuNhapXuat.HoanThanh.GetHashCode(),
                                    true,
                                    DateTime.Now,
                                    OrderGuid);
                            }
                        }

                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }
            if (Request.IsAjaxRequest())
            {
                return(Json("OK", JsonRequestBehavior.AllowGet));
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult Details(int?id)
        {
            using (var db = new ShopOnlineDb())
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                Product product = db.Products.Include(x => x.ProductImages).FirstOrDefault(x => x.Id == id);

                if (product == null)
                {
                    return(HttpNotFound());
                }
                return(View(product));
            }
        }
        public ActionResult Details(int?id)
        {
            using (var db = new ShopOnlineDb())
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                NicheInformation nicheInformation = db.NicheInformations.FirstOrDefault(x => x.Id == id);

                if (nicheInformation == null)
                {
                    return(HttpNotFound());
                }
                return(View(nicheInformation));
            }
        }
Ejemplo n.º 25
0
        public ActionResult Create(int?MemberId, string MemberGuiId,
                                   string MemberName, string MemberLogin, string Password,
                                   string Address, int?Sex, string Tel,
                                   string Email, string Phone, string Notes, bool?Status,
                                   string ImageFile)
        {
            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        shMemberService _member = new shMemberService();
                        shMember        member  = _member.ThemMoi_HieuChinhMember(
                            MemberGuiId,
                            null,
                            MemberName,
                            MemberLogin,
                            Password,
                            ImageFile,
                            Address,
                            Sex,
                            Email,
                            Tel,
                            Phone,
                            Notes,
                            Status,
                            DateTime.Now,
                            null,
                            null
                            );

                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }


            return(RedirectToAction("Index"));
        }
Ejemplo n.º 26
0
        public ActionResult DialogHighLight(string ProductGuid, string ImageCarousel)
        {
            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        // 1. cập nhật ảnh đại diện sản phẩm
                        shProductService _product = new shProductService();
                        _product.UploadImageProduct(ProductGuid, ImageCarousel);

                        // 2. Upload file sản phẩm nổi bật
                        shProductImageService _productImage = new shProductImageService();
                        shProductImage        productImage  = new shProductImage();
                        productImage = _productImage.Insert_UpdateProductImage(
                            null,
                            null,
                            ProductGuid,
                            ImageCarousel,
                            null,
                            User.Identity.GetUserLogin().Userid,
                            true,
                            DateTime.Now,
                            Config.ProductImageCategory_Design,
                            Config.Product_Image_HighLight
                            );

                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }

            if (Request.IsAjaxRequest())
            {
                return(Json("OK", JsonRequestBehavior.AllowGet));
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 27
0
        public ActionResult Create(string SaleGuid, string SaleName,
                                   string SaleCode, int?SaleStatus, string Description,
                                   string StartTime, string EndTime, int?CachTinhGiaTriKhuyenMai,
                                   decimal?Percent, double?USD, int?DieuKienApDung,
                                   string[] CagegoryChild,
                                   string[] ProductGuid1)
        {
            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        shSaleService _sale = new shSaleService();
                        shSale        sale  = _sale.ThemMoi_CapNhatKhuyenMai(
                            SaleGuid,
                            SaleName,
                            SaleCode,
                            SaleStatus,
                            Description,
                            StartTime,
                            EndTime,
                            CachTinhGiaTriKhuyenMai,
                            Percent,
                            USD,
                            DieuKienApDung,
                            CagegoryChild,
                            ProductGuid1,
                            User.Identity.GetUserLogin().Userid,
                            true,
                            DateTime.Now);

                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 28
0
        public ActionResult CheckOut([Bind(Include = "Code,Status,CreatedDate,ContactName,ContactAddress,ContactPhone,ContactEmail")] Order order)
        {
            using (var db = new ShopOnlineDb())
            {
                if (ModelState.IsValid)
                {
                    var shoppingCart = (ShoppingCart)Session["ShoppingCart"];
                    foreach (var item in shoppingCart.ShoppingCartItems)
                    {
                        var orderDetail = new OrderDetail();
                        orderDetail.ProductId = item.Item.Id;
                        orderDetail.Quantity  = item.Quantity;
                        orderDetail.Discount  = item.Item.Discount;
                        if (item.Item.Discount > 0)
                        {
                            orderDetail.Price = item.Item.Price * (100 - item.Item.Discount) / 100;
                        }
                        else
                        {
                            orderDetail.Price = item.Item.Price;
                        }

                        order.OrderDetails.Add(orderDetail);
                    }

                    db.Orders.Add(order);
                    db.SaveChanges();
                    string content = System.IO.File.ReadAllText(Server.MapPath("~/Client/NewOrder.html"));

                    content = content.Replace("{{CustomerName}}", order.ContactName);
                    content = content.Replace("{{Address}}", order.ContactAddress);
                    content = content.Replace("{{Phone}}", order.ContactPhone);

                    var toEmail = ConfigurationManager.AppSettings["ToEmailAddress"].ToString();
                    new MailHelper().SendMail(toEmail, "Đơn đặt hàng mới từ XanhDiepLuc store", content);

                    Session["ShoppingCart"] = null;
                    return(RedirectToAction("OrderSuccessNotification", "Home"));
                }
                return(View(order));
            }
        }
Ejemplo n.º 29
0
        public ActionResult Create(string AboutGuid, string AboutTitle, string AboutName,
                                   string AboutContent, int?Year, string Parent, string Sign,
                                   string ImageUrl, int?SortOrder,
                                   bool?Status, string Url)
        {
            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        shAboutService _about = new shAboutService();
                        shAboutu       about  = new shAboutu();

                        about = _about.Insert_About(
                            AboutGuid,
                            null,
                            AboutTitle,
                            AboutName,
                            AboutContent,
                            Year,
                            Sign,
                            ImageUrl,
                            Parent,
                            SortOrder,
                            Status,
                            DateTime.Now);

                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }



            return(RedirectToAction("Index"));
        }
Ejemplo n.º 30
0
        public void UpdateCart(int ProductId, decimal Quantity)
        {
            using (var db = new ShopOnlineDb())
            {
                // TÌM PRODUCT THEO ProductId
                var product = db.Products.Find(ProductId);
                if (product != null)
                {
                    // XE HÀNG
                    var shoppingCart = new ShoppingCart();
                    if (Session["ShoppingCart"] != null)
                    {
                        shoppingCart = (ShoppingCart)Session["ShoppingCart"];
                    }

                    shoppingCart.UpdateCart(product, Quantity);

                    Session["ShoppingCart"] = shoppingCart;
                }
            }
        }