Ejemplo n.º 1
0
        public ActionResult OnEdit(ProductImageModels productImage)
        {
            var productImageUpdate = ProductImageService.Find(productImage.Id);

            if (productImageUpdate == null)
            {
                return(RedirectToAction("Edit", "Product", new
                {
                    id = productImage.ProductId
                }));
            }
            productImageUpdate.Name = productImage.Image != null?
                                      productImage.Image.Upload() :
                                          productImage.ImageUrl.ToImageOriginalPath();

            productImageUpdate.ProductID = productImage.ProductId;
            productImageUpdate.Title     = productImage.Title;
            productImageUpdate.Number    = Convert.ToInt32(productImage.Number);
            var result = ProductImageService.Update(productImageUpdate);

            if (result == Result.NotExists)
            {
                ModelState.AddModelError("", "Id không tồn tại trên hệ thống.");
                return(View("Edit", productImage));
            }
            SetFlashMessage($"Cập nhật ảnh '{productImageUpdate.Title}' thành công.");
            if (productImage.SaveList)
            {
                return(RedirectToAction("Edit", "Product", new
                {
                    id = productImage.ProductId
                }));
            }
            return(View("Edit", productImage));
        }
 public ProductsController(IProductRepository repository, ProductImageService productImageService, IProductCacheService productCacheService, IHubContext <NotifyHub> hubContext)
 {
     this.repository          = repository;
     this.productImageService = productImageService;
     this.productCacheService = productCacheService;
     this.hubContext          = hubContext;
 }
Ejemplo n.º 3
0
 public StoreController()
 {
     svProduct      = new Product.ProductService();
     svProductImage = new ProductImageService();
     svCategory     = new CategoryService();
     svBizType      = new Ouikum.BizType.BizTypeService();
     svCompany      = new CompanyService();
 }
Ejemplo n.º 4
0
 public ProductController()
 {
     svProduct      = new ProductService();
     svProductImage = new ProductImageService();
     svCategory     = new CategoryService();
     svBizType      = new Ouikum.BizType.BizTypeService();
     svCompany      = new CompanyService();
     svAddress      = new AddressService();
 }
 public ActionResult ViewProductImage(int id)
 {
     if (id > 0)
     {
         var model = new ProductImageService().GetProductImage(id);
         return(View(model));
     }
     return(View());
 }
Ejemplo n.º 6
0
        public static async Task <IEnumerable <ProductImage> > GetShopifyProductImages(IConfiguration appConfig, long productId)
        {
            // get shopify configuration parameters
            var    config             = new MyConfiguration(appConfig);
            string shopifyDomain      = config.GetString("ShopifyDomain");
            string shopifyAPIPassword = config.GetString("ShopifyAPIPassword");

            var service = new ProductImageService(shopifyDomain, shopifyAPIPassword);

            return(await service.ListAsync(productId));
        }
Ejemplo n.º 7
0
        public ActionResult Edit(int id, int productId)
        {
            var productImage = ProductImageService.Find(id);

            if (productImage == null)
            {
                return(RedirectToAction("Edit", "Product", new
                {
                    id = productId
                }));
            }
            return(View("Edit", productImage.CloneTo <ProductImageModels>()));
        }
        public ActionResult ProductDetail(int?id)
        {
            if (RedirectToProduction())
            {
                return(Redirect(UrlProduction));
            }

            GetStatusUser();
            svProductImage = new ProductImageService();
            svProduct      = new ProductService();
            svCompany      = new CompanyService();
            string page   = "Product";
            int    CompID = Convert.ToInt32(Request.Cookies["WebsiteCompID"].Value);

            DefaultWebsite((int)CompID, page);

            var Products = svProduct.SelectData <view_Product>("*", "ProductID = " + id, null, 1, 0);

            ViewBag.Product = Products;

            if (Products != null)
            {
                ViewBag.ProductDetail = Products.First();

                string sqlWhere    = "CompID = " + CompID + " AND RowFlag > 0 AND IsShow = 1 AND IsJunk = 0";
                var    ImgProducts = svProduct.SelectData <view_Product>("ProductID,ProductImgPath,ProductName", sqlWhere, null, 1, 0, false);
                ViewBag.ProductImageAll = ImgProducts;
                ViewBag.ImageCount      = ImgProducts.Count;

                var ProductImages = svProductImage.SelectData <view_ProductImage>("*", "ProductID = " + id, null, 1, 0, false);
                ViewBag.ProductImage = ProductImages;

                var Companies = svCompany.SelectData <view_Company>("*", "CompID = " + CompID, null, 1, 0, false);
                ViewBag.Company = Companies.First();

                var Shipments = svProduct.SelectData <view_ProductShipment>("*", "CompID = " + CompID, null, 1, 0, false);
                ViewBag.ProductShipment = Shipments;

                var Payments = svProduct.SelectData <view_ProductPayment>("*", "CompID = " + CompID, null, 1, 0, false);
                ViewBag.ProductShipment = Payments;

                ViewBag.CompID = CompID;
            }
            ViewBag.ProID = (int)id;


            return(View());
        }
Ejemplo n.º 9
0
        public void Init()
        {
            // set up the ProductImageService
            productImageService                 = new ProductImageService();
            productImageService.Credentials     = new System.Net.NetworkCredential(WEBSERVICE_LOGIN, WEBSERVICE_PASSWORD);
            productImageService.PreAuthenticate = true;
            productImageService.Url             = WEBSERVICE_URL;

            // set up the ProductService in order to create a test product
            productService                 = new ProductService();
            productService.Credentials     = new System.Net.NetworkCredential(WEBSERVICE_LOGIN, WEBSERVICE_PASSWORD);
            productService.PreAuthenticate = true;
            productService.Url             = WEBSERVICE_URL;

            // create the test product
            TCreate_Input productInfo = new TCreate_Input();

            productInfo.Alias = alias;
            TCreate_Input[] createInput = new TCreate_Input[] { productInfo };
            productService.create(createInput);
        }
Ejemplo n.º 10
0
        public async Task Post(Customer obj)
        {
            var    shop     = _context.Shopify.Single(b => b.StoreName == obj.StoreName);
            string Token    = shop.Token;
            string store    = shop.StoreName;
            var    service  = new ProductService(store, Token);
            var    service1 = new CustomerService(store, Token);
            var    service2 = new ProductVariantService(store, Token);
            var    service3 = new ProductImageService(store, Token);


            var product = await service.GetAsync(long.Parse(obj.product_id));

            var customer = await service1.GetAsync(long.Parse(obj.customer_id));

            obj.customer_name  = customer.FirstName;
            obj.customer_email = customer.Email;

            obj.product_title = product.Title;


            var variant = await service2.GetAsync(long.Parse(obj.variant_id));

            obj.variant_sku     = variant.SKU;
            obj.variant_barcode = variant.Barcode;

            // var image = await service3.GetAsync(long.Parse(obj.product_id), (long)variant.ImageId);

            IEnumerable <ProductImage> obj1 = product.Images;

            obj.variant_image = obj1.ElementAt(0).Src;



            _context.Add(obj);
            await _context.SaveChangesAsync();
        }
        public JsonResult ProductImagesByPaging(DataTablesPaging request)
        {
            var view = new ProductImageService().GetProductImagesByPaging(request);

            return(Json(view, JsonRequestBehavior.AllowGet));
        }
        public JsonResult ProductImages()
        {
            var items = new ProductImageService().GetProductImages();

            return(Json(items, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 13
0
        public JsonResult OnDelete(int id)
        {
            var result = ProductImageService.Delete(id);

            return(Json(new { code = result }));
        }
        public ActionResult PrepareEditByID(int ID, string GenCode)
        {
            var           svProduct      = new ProductService();
            var           svCategory     = new CategoryService();
            var           svProductGroup = new ProductGroupService();
            var           svProductImage = new ProductImageService();
            CommonService svCommon       = new CommonService();

            #region FindCateAll

            //var sqlwherein = "";
            //switch (res.Common.lblWebsite)
            //{
            //    case "B2BThai": sqlwherein = " AND CategoryType IN (1,2)"; break;
            //    case "AntCart": sqlwherein = " AND CategoryType IN (3)"; break;
            //    case "myOtopThai": sqlwherein = " AND CategoryType IN (5)"; break;
            //    case "AppstoreThai": sqlwherein = " AND CategoryType IN (6)"; break;
            //    default: sqlwherein = ""; break;
            //}

            var sqlSelect = "CategoryID,CategoryName";
            var sqlWhere  = "CategoryLevel=1 AND RowFlag > 0 AND IsDelete=0";
            var data1     = svCategory.GetCategoryByLevel(1);
            //var data2 = svCategory.GetCategoryByLevel(2);
            //var data3 = svCategory.GetCategoryByLevel(3);
            ViewBag.SelectCateLV1 = data1;
            //ViewBag.SelectCateLV2 = data2;
            //ViewBag.SelectCateLV3 = data3;
            #endregion

            ViewBag.QtyUnits = svCommon.SelectEnum(CommonService.EnumType.QtyUnits);

            #region Set Product Group
            var ProductGroups = svProductGroup.GetProductGroup(LogonCompID);
            if (ProductGroups.Count() > 0)
            {
                ViewBag.ProductGroups = ProductGroups;
            }
            else
            {
                ViewBag.ProductGroups = null;
            }
            #endregion
            var Product = svProduct.SelectData <b2bProduct>(" * ", "ProductID=" + ID + " And IsDelete=0", null, 1, 1).First();
            ViewBag.Product = Product;

            sqlSelect = "ProductID,ProductImageID,ImgPath,ListNo";
            sqlWhere  = svProductImage.CreateWhereCause(ID);

            var Images   = svProductImage.SelectData <b2bProductImage>(sqlSelect, sqlWhere, " ListNo ASC");
            var countImg = 0;

            if (svProductImage.TotalRow > 0)
            {
                countImg = Images.Where(m => m.ImgPath == Product.ProductImgPath).Count();
            }

            if (countImg == 0)
            {
                var img = new b2bProductImage();
                img.ProductID = Product.ProductID;
                img.ListNo    = 1;
                img.ImgPath   = Product.ProductImgPath;
                img.ImgDetail = Product.ProductName;
                svProductImage.InsertProductImage(img);

                Images = svProductImage.SelectData <b2bProductImage>(sqlSelect, sqlWhere, " ListNo DESC");
            }

            ViewBag.ProductImg = Images;
            ViewBag.ImgCount   = Images.Count();

            var data2 = new List <b2bCategory>();
            var data3 = new List <b2bCategory>();
            data2 = svCategory.LoadSubCategory(DataManager.ConvertToInteger(Product.CateLV1), 500, 2);
            data3 = svCategory.LoadSubCategory(DataManager.ConvertToInteger(Product.CateLV2), 500, 3);
            ViewBag.SelectCateLV2 = data2;
            ViewBag.SelectCateLV3 = data3;

            var a = svCategory.SearchCategoryByID((int)Product.CateLV3);
            //var a = svCategory.SelectData<b2bCategory>("*", "CategoryID = " + (int)Product.CateLV3, null, 1, 1,);
            ViewBag.Catename    = a;
            ViewBag.ProductCode = GenCode;
            return(PartialView("UC/EditProduct"));
        }
Ejemplo n.º 15
0
        public ActionResult OnEdit(ProductModels product)
        {
            var productUpdate = ProductService.Find(product.Id);

            if (productUpdate != null)
            {
                if (string.IsNullOrWhiteSpace(product.Code))
                {
                    product.Code = $"MP-{DateTime.Now.Ticks.GetHashCode()}";
                }
                product.ImageUrl = product.Image != null?
                                   product.Image.Upload() :
                                       product.ImageUrl.ToImageOriginalPath();

                productUpdate.Name         = product.Name;
                productUpdate.Type         = product.CategoryId;
                productUpdate.Summary      = product.Summary;
                productUpdate.Code         = product.Code;
                productUpdate.Image        = product.ImageUrl;
                productUpdate.BrandId      = product.BrandId;
                productUpdate.Country      = product.Country;
                productUpdate.Store        = product.Store;
                productUpdate.Manufacturer = product.ManufacturerId;
                productUpdate.AccountId    = product.AccountId;
                productUpdate.Number       = product.Number;
                productUpdate.Unit1        = product.Unit;
                productUpdate.Weight       = product.Weight;
                productUpdate.Quantity     = product.Quantity;
                productUpdate.Npp          = Convert.ToDouble(product.Npp);
                productUpdate.Width        = product.Width;
                productUpdate.Height       = product.Height;
                productUpdate.Depth        = product.Depth;
                productUpdate.Detail       = product.Detail;
                productUpdate.WarrantyTime = product.WarrantyTime;
                productUpdate.ExpireDate   = product.ExpireDate;
                productUpdate.Title        = product.MetaTitle;
                productUpdate.Keyword      = product.MetaKeyword;
                productUpdate.Description  = product.MetaDescription;
                productUpdate.Price        = product.Price;
                productUpdate.Transport1   = product.Transport1;
                productUpdate.Transport2   = product.Transport2;
                var result = ProductService.Update(productUpdate);
                //Tao cac anh san pham
                if (product.ProductImages != null && product.ProductImages.Length > 0)
                {
                    ProductImageService.Insert(productUpdate.ID, product.Name, product.ProductImages);
                }
                //Tao cac gia tri thuoc tinh
                if (product.AttrLabel != null && product.AttrLabel.Length > 0)
                {
                    ProductAttributeService.Insert(productUpdate.ID, product.AttrLabel, product.AttrDesc);
                }
                //Tao saleOff
                if (!string.IsNullOrWhiteSpace(product.Percent))
                {
                    ProductSaleOffService.Insert(new ProductSaleOff
                    {
                        ProductID = productUpdate.ID,
                        Percent   = Convert.ToDouble(product.Percent),
                        StartTime = Convert.ToDateTime(product.StartDate),
                        EndTime   = Convert.ToDateTime(product.EndDate)
                    });
                }
                //Tao kich co
                if (product.Size != null && product.Size.Length > 0)
                {
                    ProductSizeService.Insert(productUpdate.ID, product.Size);
                }
                //Tao mau sac
                if (product.Color != null && product.Color.Length > 0)
                {
                    ProductColorService.Insert(productUpdate.ID, product.Color);
                }

                SetFlashMessage(result == Result.Ok?
                                $"Cập nhật sản phẩm '{product.Name}' thành công.":
                                "Lỗi khi cập nhật sản phẩm '{product.Name}'"
                                );
                if (product.SaveList)
                {
                    return(RedirectToAction("Index"));
                }
                ViewBag.ListCategory     = BuildListCategory();
                ViewBag.ListBrand        = ProductBrandService.GetAll();
                ViewBag.ListCountry      = CountryService.GetAll();
                ViewBag.ListStore        = ProductStoreService.GetAll();
                ViewBag.ListManufacturer = ProductManufacturerService.GetAll();
                ViewBag.ListUnit         = UnitService.GetAll();
                ViewBag.ListColor        = BuildListColor(product.Color);
                ViewBag.ListSize         = BuildListSize(product.Size);
                ViewBag.ListHour         = DataHelper.ListHour;
                return(View("Edit", product));
            }
            ViewBag.ListBrand        = ProductBrandService.GetAll();
            ViewBag.ListCountry      = CountryService.GetAll();
            ViewBag.ListStore        = ProductStoreService.GetAll();
            ViewBag.ListManufacturer = ProductManufacturerService.GetAll();
            ViewBag.ListUnit         = UnitService.GetAll();
            ViewBag.ListColor        = BuildListColor(product.Color);
            ViewBag.ListSize         = BuildListSize(product.Size);
            ViewBag.ListHour         = DataHelper.ListHour;
            return(View("Edit", product));
        }
Ejemplo n.º 16
0
        public ActionResult OnCreate(ProductModels product)
        {
            if (ModelState.IsValid)
            {
                if (string.IsNullOrWhiteSpace(product.Code))
                {
                    product.Code = string.Format("{0}-{1}", ConfigHelper.ProductCode, DateTime.Now.Ticks.GetHashCode());
                }
                product.ImageUrl = product.Image != null?
                                   product.Image.Upload() :
                                       product.ImageUrl;

                var newProduct = new Product
                {
                    Name         = product.Name,
                    Type         = product.CategoryId,
                    Summary      = product.Summary,
                    Code         = product.Code,
                    Image        = product.ImageUrl,
                    BrandId      = product.BrandId,
                    Country      = product.Country,
                    Store        = product.Store,
                    Manufacturer = product.ManufacturerId,
                    AccountId    = 0,
                    Number       = product.Number,
                    Unit1        = product.Unit,
                    Weight       = product.Weight,
                    Quantity     = product.Quantity,
                    Npp          = Convert.ToDouble(product.Npp),
                    Width        = product.Width,
                    Height       = product.Height,
                    Depth        = product.Depth,
                    Detail       = product.Detail,
                    WarrantyTime = product.WarrantyTime,
                    ExpireDate   = product.ExpireDate,
                    Title        = product.MetaTitle,
                    Keyword      = product.MetaKeyword,
                    Description  = product.MetaDescription,
                    Price        = product.Price,
                    Transport1   = product.Transport1,
                    Transport2   = product.Transport2,
                    Status       = false
                };
                var result = ProductService.Insert(newProduct);

                //Tao cac anh Slide va properties
                if (product.ProductImages != null && product.ProductImages.Length > 0)
                {
                    ProductImageService.Insert(newProduct.ID, product.Name, product.ProductImages);
                }
                //Tao cac gia tri thuoc tinh
                if (product.AttrLabel != null && product.AttrLabel.Length > 0)
                {
                    ProductAttributeService.Insert(newProduct.ID, product.AttrLabel, product.AttrDesc);
                }
                //Tao saleOff
                if (!string.IsNullOrWhiteSpace(product.Percent))
                {
                    ProductSaleOffService.Insert(new ProductSaleOff
                    {
                        ProductID = newProduct.ID,
                        Percent   = Convert.ToDouble(product.Percent),
                        StartTime = Convert.ToDateTime(product.StartDate),
                        EndTime   = Convert.ToDateTime(product.EndDate)
                    });
                }
                //Tao kich co
                if (product.Size != null && product.Size.Length > 0)
                {
                    ProductSizeService.Insert(newProduct.ID, product.Size);
                }
                //Tao mau sac
                if (product.Color != null && product.Color.Length > 0)
                {
                    ProductColorService.Insert(newProduct.ID, product.Color);
                }
                SetFlashMessage(result == Result.Ok?
                                $"Thêm sản phẩm '{product.Name}' thành công.":
                                "Lỗi khi thêm mới sản phẩm");
                if (product.SaveList)
                {
                    return(RedirectToAction("Index"));
                }
                ViewBag.ListCategory     = BuildListCategory();
                ViewBag.ListBrand        = ProductBrandService.GetAll();
                ViewBag.ListCountry      = CountryService.GetAll();
                ViewBag.ListStore        = ProductStoreService.GetAll();
                ViewBag.ListManufacturer = ProductManufacturerService.GetAll();
                ViewBag.ListUnit         = UnitService.GetAll();
                ViewBag.ListColor        = BuildListColor(product.Color);
                ViewBag.ListSize         = BuildListSize(product.Size);
                ViewBag.ListHour         = DataHelper.ListHour;
                ModelState.Clear();
                return(View("Create", product.ResetValue()));
            }
            ViewBag.ListCategory     = BuildListCategory();
            ViewBag.ListBrand        = ProductBrandService.GetAll();
            ViewBag.ListCountry      = CountryService.GetAll();
            ViewBag.ListStore        = ProductStoreService.GetAll();
            ViewBag.ListManufacturer = ProductManufacturerService.GetAll();
            ViewBag.ListUnit         = UnitService.GetAll();
            ViewBag.ListColor        = BuildListColor(product.Color);
            ViewBag.ListSize         = BuildListSize(product.Size);
            ViewBag.ListHour         = DataHelper.ListHour;

            return(View("Create", product));
        }
        public ActionResult AddProduct
        (
            #region Param
            string ProductName,
            int?ProductGroup,
            string ProductCode,
            string Price,
            string Price_One,
            string Keyword,
            string QuickDetail,
            string FullDetail,
            string Qty,
            string QtyUnit,
            string Catecode,
            string CateLV3,
            List <string> ProductImgPath,
            int Ispromotion,
            string PromotionPrice
            #endregion
        )
        {
            var svProduct      = new ProductService();
            var svProductImage = new ProductImageService();

            b2bProduct model = new b2bProduct();

            try
            {
                #region Set Product Model
                model.ProductName      = ProductName;
                model.ProductGroupID   = (ProductGroup > 0) ? ProductGroup : 0;
                model.ProductCode      = ProductCode;
                model.Price            = DataManager.ConvertToDecimal(Price);
                model.Price_One        = DataManager.ConvertToDecimal(Price_One);
                model.ProductKeyword   = Keyword;
                model.ShortDescription = QuickDetail;
                model.ProductDetail    = FullDetail;
                model.Qty = DataManager.ConvertToDecimal(Qty);
                //model.QtyUnit = QtyUnit;
                model.ProductImgPath = ProductImgPath[0];
                model.IsPromotion    = DataManager.ConvertToBool(Ispromotion);
                model.PromotionPrice = DataManager.ConvertToDecimal(PromotionPrice);
                model.CompID         = LogonCompID;
                model.CateLV1        = Convert.ToInt32(Catecode.Substring(9, 4));
                model.CateLV2        = Convert.ToInt32(Catecode.Substring(14, 4));
                model.CateLV3        = Convert.ToInt32(CateLV3);
                model.IsShow         = true;
                model.IsJunk         = false;
                model.Complevel      = DataManager.ConvertToShort(LogonCompLevel);
                if (QtyUnit == "0")
                {
                    model.QtyUnit = "รายการ";
                }
                else
                {
                    model.QtyUnit = QtyUnit;
                }
                #region Check ว่าเป็น OutSource Add หรือ User Add
                if (LogonServiceType >= 9)
                {
                    model.RowFlag  = (short)2;
                    model.CompCode = LogonCompCode;
                }
                else
                {
                    model.RowFlag = (short)6;
                }
                #endregion

                model.ContactCount   = 0;
                model.ListNo         = 0;
                model.ViewCount      = 0;
                model.QuotationCount = 0;
                model.TelCount       = 0;
                model.CreatedDate    = DateTime.Now;
                model.ModifiedDate   = DateTime.Now;
                model.CreatedBy      = LogonCompCode;
                model.ModifiedBy     = LogonCompCode;
                #endregion

                #region Set ProductImage Model
                int i           = 1;
                var ProductImgs = new List <b2bProductImage>();
                foreach (var imgname in ProductImgPath)
                {
                    var modelImg = new b2bProductImage();
                    modelImg.ImgDetail    = imgname.Substring(0, 15);
                    modelImg.ListNo       = i;
                    modelImg.ImgPath      = imgname;
                    modelImg.RowVersion   = 1;
                    modelImg.RowFlag      = 1;
                    modelImg.CreatedDate  = DateTime.Now;
                    modelImg.ModifiedDate = DateTime.Now;
                    modelImg.CreatedBy    = "sa";
                    modelImg.ModifiedBy   = "sa";
                    ProductImgs.Add(modelImg);
                    i++;
                }
                #endregion

                #region Insert Product And ProductImage
                svProduct.InsertProduct(model, ProductImgs, LogonCompID, LogonCompLevel);
                svProduct.UpdateProductCountInCategories(Convert.ToInt32(Catecode.Substring(9, 4)), Convert.ToInt32(Catecode.Substring(14, 4)), Convert.ToInt32(CateLV3));
                svProduct.UpdateProductCountInCompany(LogonCompID);
                #endregion

                #region Save Image Files
                imgManager         = new FileHelper();
                imgManager.DirPath = "Product/" + LogonCompID + "/" + model.ProductID;


                if (Request.Cookies["AddProduct"] != null)
                {
                    imgManager.DirTempPath = Request.Cookies["AddProduct"]["UnRegis"];
                    HttpCookie myCookie = new HttpCookie("AddProduct");
                    myCookie.Expires = DateTime.Now.AddDays(-1d);
                    Response.Cookies.Add(myCookie);
                }
                else
                {
                    imgManager.DirTempPath = "Temp/Product/" + LogonCompID;
                }


                SaveFileImage(
                    imgManager.DirTempPath,
                    imgManager.DirPath,
                    ProductImgPath, 150, 450);
                #endregion

                //var mgKeyword = new KeywordMongo();
                //var isresult = mgKeyword.UpdateMongoProduct(model.ProductID);
            }
            catch (Exception ex)
            {
                CreateLogFiles(ex);
            }


            return(Json(new { IsResult = svProduct.IsResult, MsgError = GenerateMsgError(svProduct.MsgError), ID = model.ProductID }));
        }