public void List_DoloadDataProduct(ProductAction action) { var svProduct = new ProductService(); string sqlSelect, sqlWhere, sqlOrderBy = ""; sqlSelect = "ProductID,ProductName,Price_One,Qty,QtyUnit,Price,RowFlag,CompID,CompName"; sqlWhere = "( IsDelete = 0 AND RowFlag IN (4) AND CompRowFlag IN (2,4) AND CompIsDelete = 0) AND ( IsShow = 1 AND IsJunk = 0 ) ";//svProduct.CreateWhereAction(action) + sqlOrderBy = " CreatedDate DESC "; #region DoWhereCause sqlWhere += svProduct.CreateWhereCause(0, "", (int)ViewBag.PStatus); sqlWhere += svProduct.CreateWhereSearchBy(ViewBag.TextSearch, ViewBag.SearchType); if (!string.IsNullOrEmpty(ViewBag.Period)) { sqlWhere += SQLWhereDateTimeFromPeriod(ViewBag.Period, "CreatedDate"); } #endregion var products = svProduct.SelectData <view_SearchProduct>(sqlSelect, sqlWhere, sqlOrderBy, (int)ViewBag.PageIndex, (int)ViewBag.PageSize); ViewBag.Products = products; ViewBag.LogonCompID = LogonCompID; ViewBag.TotalRow = svProduct.TotalRow; ViewBag.TotalPage = svProduct.TotalPage; }
public async Task SetProductsActionAsync(List <Product> products, ProductAction productAction) { // Get all products for this client List <ProductOnClient> productsOnClient = await GetAllAsync().ConfigureAwait(false); // Get all products that aren't already created for this client List <Product> notCreatedProducts = products.Where(product => productsOnClient.All(productOnClient => productOnClient.ProductId != product.Id)).ToList(); // Create objects if any need to be created foreach (var product in notCreatedProducts) { await CreateProductAsync(product).ConfigureAwait(false); } // Update productsOnClient only if there are new products for this client if (notCreatedProducts.Any()) { productsOnClient = await GetAllAsync().ConfigureAwait(false); } // Get all Products On Client that should be applied productsOnClient = productsOnClient.Where(productOnClient => products.Any(product => product.Id == productOnClient.ProductId)).ToList(); // Set Action for all products productsOnClient.ForEach(productOnClient => productOnClient.ActionRequest = productAction.ToOpsiName()); await OpsiHttpClient.ExecuteAsync <List <string> >(new Request(GetFullMethodName("updateObjects")).AddParametersAsJArray(productsOnClient)).ConfigureAwait(false); }
public List <view_ProductMobileApp> SearchProduct( ProductAction action, string textsearch, int CateLV = 0, int CateID = 0, int Biztype = 0, int ProvinceID = 0, int CompID = 0, int pageindex = 1, int pagesize = 20, string SQLOrderBy = " Complevel DESC, ListNo DESC , ModifiedDate DESC ") { SQLWhere = CreateWhereAction(action, 0); SQLWhere += CreateWhereCause(0, textsearch, 0, 0, CateLV, CateID, Biztype, 0, ProvinceID); SQLSelect = @" ProductID, ProductName, ShortDescription, Price, Price_One, Qty, QtyUnit,"; SQLSelect += " ProductImgPath, CompID, ViewCount,ListNo , "; SQLSelect += " CateLV3, CreatedDate, ModifiedDate, RowFlag, "; SQLSelect += "CompName, ContactMobile, Complevel, "; SQLSelect += "ServiceType, CompProvinceID, CompDistrictID, BizTypeID, BizTypeOther, ContactCount, IsSME "; var Products = SelectData <view_ProductMobileApp>(SQLSelect, SQLWhere, SQLOrderBy, pageindex, pagesize); return(Products); }
ProductAction generateCheckoutProductAction(ActionData actionData, ProductActions productAction) { var pAction = new ProductAction(productAction.ToString()); if (actionData != null) { if (string.IsNullOrEmpty(actionData?.Id) && (productAction == ProductActions.purchase || productAction == ProductActions.refund)) { return(pAction); } else if (!string.IsNullOrEmpty(actionData?.Id)) { pAction.SetTransactionId(actionData.Id); } if (!string.IsNullOrEmpty(actionData?.Affiliation)) { pAction.SetTransactionAffiliation(actionData.Affiliation); } if (actionData?.Revenue != 0) { pAction.SetTransactionRevenue(actionData.Revenue); } if (actionData?.Tax != 0) { pAction.SetTransactionTax(actionData.Tax); } if (actionData?.Shipping != 0) { pAction.SetTransactionShipping(actionData.Shipping); } if (!string.IsNullOrEmpty(actionData?.Coupon)) { pAction.SetTransactionCouponCode(actionData.Coupon); } if (!string.IsNullOrEmpty(actionData?.List)) { pAction.SetProductActionList(actionData.List); } if (actionData?.Step != 0) { pAction.SetCheckoutStep(actionData.Step); } if (!string.IsNullOrEmpty(actionData?.Option)) { pAction.SetCheckoutOptions(actionData.Option); } } return(pAction); }
public void RemoveProduct(string userId, int productId, ApiProdAction info) { using var context = _di.GetService <ApplicationDbContext>(); var from = getStockAndVerify(productId, info, context); using var transaction = context.Database.BeginTransaction(); try { var date = DateTime.UtcNow; var action = new ProductAction() { ProductId = productId, Quantity = -info.Quantity, WarehouseId = info.FromId, Description = info.Description, UserId = userId, Date = date, Operation = OperationDescription.Delete }; context.ProductsTrqansactions.Add(action); context.SaveChanges(); // Commit transaction if all commands succeed, // transaction will auto-rollback when disposed if either commands fails transaction.Commit(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); // TODO: Handle failure throw; } }
public static string ToOpsiName(this ProductAction productAction) { switch (productAction) { case ProductAction.Setup: return("setup"); case ProductAction.Update: return("update"); case ProductAction.Uninstall: return("uninstall"); case ProductAction.Always: return("always"); case ProductAction.Once: return("once"); case ProductAction.Custom: return("custom"); case ProductAction.None: return("none"); } throw new ArgumentException($"{productAction} is not a valid product type"); }
public JsonResult CreateOrder(int Id_Product) { if (Session["order"] == null) { Dictionary <int, Item> order = new Dictionary <int, Item>(); order.Add(Id_Product, new Item { product = ProductAction.Find_By_Id(Id_Product), quantity = 1 }); Session["order"] = order; } else { Dictionary <int, Item> order = (Dictionary <int, Item>)Session["order"]; if (order.ContainsKey(Id_Product)) { var tmp = order[Id_Product]; tmp.quantity = tmp.quantity + 1; order[Id_Product] = tmp; } else { order.Add(Id_Product, new Item { product = ProductAction.Find_By_Id(Id_Product), quantity = 1 }); } } return(Json("Good", JsonRequestBehavior.AllowGet)); }
public async Task SellOrderAsync(string userId, ApiSellOrder info) { var changesNotes = new List <ApiProdCountChange>(); await _semaphoreSlim.WaitAsync(); try { await using (var context = _di.GetRequiredService <ApplicationDbContext>()) { await using (var transaction = await context.Database.BeginTransactionAsync(IsolationLevel.ReadCommitted)) { var date = DateTime.UtcNow; var order = _mapper.Map <Order>(info); order.OpenDate = date; order.Status = OrderStatus.Open; order.ResponsibleUserId = userId; order.Transactions = new List <ProductAction>(); foreach (var productOrder in info.ProductOrders) { var from = getStockAndVerify(productOrder.IdProduct, productOrder, context); changesNotes.Add(new ApiProdCountChange { ProductId = productOrder.IdProduct, WarehouseId = productOrder.FromId, NewCount = from.Quantity, OldCount = from.Quantity + productOrder.Quantity }); var prodOrder = new ProductAction { Date = date, ProductId = productOrder.IdProduct, Quantity = -productOrder.Quantity, WarehouseId = productOrder.FromId, Description = productOrder.Description, Price = productOrder.Price, BuyPrice = from.Product.RecommendedBuyPrice, UserId = userId, Operation = OperationDescription.Sold }; order.Transactions.Add(prodOrder); } context.Orders.Add(order); await context.SaveChangesAsync(); await transaction.CommitAsync(); } } await Informer.ProductsCountChangedAsync(changesNotes).ConfigureAwait(false); } finally { _semaphoreSlim.Release(); } }
public ActionResult ProductManager() { if (Session["role"] != null && (string)Session["role"] == "Manager") { ViewBag.Product = ProductAction.Get_Product(); return(View()); } else { return(Redirect("~/Home/Index")); } }
public ActionResult ShowProduct() { if (Session["id"] != null) { ViewBag.Product = ProductAction.Get_Product(); return(View()); } else { return(Redirect("~/Home/Index")); } }
public void CommerceEvents() { var product = new Product("product-id", "product-name") { TotalProductAmount = new Decimal(123.12), }; var productAction = new ProductAction(ProductAction.ActionEnum.Purchase) { TotalAmount = new Decimal(123.12), TransactionId = "foo-transaction-id" }; var commerceEvent = new CommerceEvent(productAction); }
public ActionResult ProductRestore() { if (Session["role"] != null && (string)Session["role"] == "Manager") { ViewBag.Product = ProductAction.Get_Delete_Product(); ViewBag.Table = TableAction.Get_Table_Delete(); return(View()); } else { return(Redirect("~/Home/Index")); } }
public List <Product> GetProductsFacade(ProductAction productResultType, string productType = "") { switch (productResultType) { case ProductAction.GetAllProducts: return(GetAllProducts()); case ProductAction.GetProductsForProductTypeID: return(GetProductsForProductTypeID(productType)); default: return(null); } }
public string CreateWhereAction(ProductAction action, int?CompID = 0) { var sqlWhere = string.Empty; #region Condition if (action == ProductAction.All) { sqlWhere = "( IsDelete = 0 ) "; } else if (action == ProductAction.FrontEnd) { //comprowflag มาจาก b2bcompany.rowflag sqlWhere = "( IsDelete = 0 AND RowFlag IN (4,5,6) AND CompRowFlag IN (2,4) AND CompIsDelete = 0) AND ( IsShow = 1 AND IsJunk = 0 )"; } else if (action == ProductAction.Home) { //comprowflag มาจาก b2bcompany.rowflag sqlWhere = "( IsDelete = 0 AND RowFlag IN (4,6) AND CompRowFlag IN (2,4) AND CompIsDelete = 0) AND ( IsShow = 1 AND IsJunk = 0 )"; } else if (action == ProductAction.BackEnd) { sqlWhere = "( IsDelete = 0 AND ( RowFlag >= 2 AND RowFlag <=6 ) AND IsJunk = 0 ) "; } else if (action == ProductAction.Junk) { sqlWhere = "( IsDelete = 0 AND ( RowFlag >= 2 AND RowFlag <=6 ) AND IsJunk = 1 ) "; } else if (action == ProductAction.Admin) { sqlWhere = "( IsDelete = 0 AND ( RowFlag >= 2 AND RowFlag <=6 ) AND CompRowFlag IN (2,4) AND IsJunk = 0 ) "; } else if (action == ProductAction.WebSite) { sqlWhere = "IsDelete = 0 "; } else if (action == ProductAction.Recommend) { sqlWhere = "( IsDelete = 0 AND RowFlag IN (4,5,6)) AND (IsShow =1 AND IsJunk = 0 AND ListNo > 0) "; } if (CompID > 0) { sqlWhere += "AND (CompID = " + CompID + ")"; } #endregion return(sqlWhere); }
public void List_DoloadData(ProductAction action) { ViewBag.PageSize = 19; var svProduct = new ProductService(); sqlSelect = "ProductID,ProductName,Price_One,Qty,QtyUnit,Price,ProductImgPath,Remark,RowFlag,CompID,CateLV1,CateLV2,CateLV3,RowVersion"; //if ((int)ViewBag.GroupID > 0) //{ } sqlWhere = svProduct.CreateWhereAction(action); //else{ // sqlWhere = svProduct.CreateWhereAction(action) + " AND ListNo = 0 "; //} //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; //} //sqlWhere += sqlwherein; sqlOrderBy = " ModifiedDate DESC "; #region DoWhereCause sqlWhere += svProduct.CreateWhereCause(LogonCompID, ViewBag.TextSearch, (int)ViewBag.PStatus, (int)ViewBag.GroupID, (int)ViewBag.CateLevel, (int)ViewBag.CateID); if (!string.IsNullOrEmpty(ViewBag.Period)) { sqlWhere += SQLWhereDateTimeFromPeriod(ViewBag.Period, "ModifiedDate"); } #endregion var products = svProduct.SelectData <view_SearchProduct>(sqlSelect, sqlWhere, sqlOrderBy, (int)ViewBag.PageIndex, (int)ViewBag.PageSize); ViewBag.Products = products; ViewBag.LogonCompID = LogonCompID; ViewBag.TotalRow = svProduct.TotalRow; ViewBag.TotalPage = svProduct.TotalPage; if (LogonCompLevel == 1) { svProduct.ValidateFullProduct(LogonCompID, LogonCompLevel); if (svProduct.IsResult) { ViewBag.IsMaxProduct = true; } } }
/// <summary> /// Sets a product action for all the products included in this hit. The action and its associated properties affect /// how the products added through <see cref="AddProduct(Product)" /> are processed. /// </summary> /// <param name="action">The product action associated with the hit.</param> /// <returns>The builder object that you can use to chain calls.</returns> public HitBuilder SetProductAction(ProductAction action) { var data = new Dictionary <string, string>(); if (action.Action != null) { data.Add("pa", action.Action); } if (action.TransactionId != null) { data.Add("ti", action.TransactionId); } if (action.TransactionAffiliation != null) { data.Add("ta", action.TransactionAffiliation); } if (action.TransactionRevenue.HasValue) { data.Add("tr", action.TransactionRevenue.Value.ToString(CultureInfo.InvariantCulture)); } if (action.TransactionTax.HasValue) { data.Add("tt", action.TransactionTax.Value.ToString(CultureInfo.InvariantCulture)); } if (action.TransactionShipping.HasValue) { data.Add("ts", action.TransactionShipping.Value.ToString(CultureInfo.InvariantCulture)); } if (action.TransactionCouponCode != null) { data.Add("tcc", action.TransactionCouponCode); } if (action.ProductActionList != null) { data.Add("pal", action.ProductActionList); } if (action.CheckoutStep.HasValue) { data.Add("cos", action.CheckoutStep.Value.ToString(CultureInfo.InvariantCulture)); } if (action.CheckoutOptions != null) { data.Add("col", action.CheckoutOptions); } return(new HitBuilder(_lineage, data)); }
public ActionResult Update_Image_Product(int Id, HttpPostedFileBase File) { string path = ""; if (File.ContentLength > 0) { string File_Name = Path.GetFileName(File.FileName); path = Path.Combine(Server.MapPath("~/UploadFiles"), File_Name); File.SaveAs(path); ProductAction.Update_Image(Id, File_Name); return(Redirect("~/Manager/ProductManager")); } else { return(Redirect("~/Manager/ProductManager")); } }
public ActionResult CreateProduct(string Name, double Price, HttpPostedFileBase File) { string path = ""; if (File.ContentLength > 0) { string File_Name = Path.GetFileName(File.FileName); path = Path.Combine(Server.MapPath("~/UploadFiles"), File_Name); File.SaveAs(path); ProductAction.Create_Product(Name, Price, File_Name); return(Redirect("~/Manager/ProductManager")); } else { return(Redirect("~/Manager/ProductManager")); } }
public void List_DoloadDataFormAddRecommend(ProductAction action) { var svProduct = new ProductService(); sqlSelect = "ProductID,ProductName,ProductImgPath,CompID"; sqlWhere = svProduct.CreateWhereAction(action, LogonCompID) + " AND ListNo = 0 AND RowFlag >=4 "; sqlOrderBy = " ModifiedDate DESC "; #region DoWhereCause sqlWhere += svProduct.CreateWhereCause(0, ViewBag.TextSearch); #endregion var products = svProduct.SelectData <b2bProduct>(sqlSelect, sqlWhere, sqlOrderBy, (int)ViewBag.PageIndex, 30); ViewBag.Products = products; ViewBag.LogonCompID = LogonCompID; ViewBag.TotalRow = svProduct.TotalRow; ViewBag.TotalPage = svProduct.TotalPage; }
internal string ConvertToMpProductAction(ProductAction action) { switch (action) { case ProductAction.AddToCart: return("add_to_cart"); case ProductAction.AddToWishlist: return("add_to_wishlist"); case ProductAction.Checkout: return("checkout"); case ProductAction.CheckoutOption: return("checkout_option"); case ProductAction.Click: return("click"); case ProductAction.Purchase: return("purchase"); case ProductAction.Refund: return("refund"); case ProductAction.RemoveFromWishlist: return("remove_from_wishlist"); case ProductAction.RemoveFromCart: return("remove_from_cart"); case ProductAction.ViewDetail: return("view_detail"); default: return(null); } }
private MPCommerceEventAction ConvertToMpProductAction(ProductAction action) { switch (action) { case ProductAction.AddToCart: return(MPCommerceEventAction.AddToCart); case ProductAction.AddToWishlist: return(MPCommerceEventAction.AddToWishList); case ProductAction.Checkout: return(MPCommerceEventAction.Checkout); case ProductAction.CheckoutOption: return(MPCommerceEventAction.CheckoutOptions); case ProductAction.Click: return(MPCommerceEventAction.Click); case ProductAction.Purchase: return(MPCommerceEventAction.Purchase); case ProductAction.Refund: return(MPCommerceEventAction.Refund); case ProductAction.RemoveFromWishlist: return(MPCommerceEventAction.RemoveFromWishlist); case ProductAction.RemoveFromCart: return(MPCommerceEventAction.RemoveFromCart); case ProductAction.ViewDetail: return(MPCommerceEventAction.ViewDetail); default: return(0); } }
public void List_DoloadDataRecommend(ProductAction action) { var svProduct = new ProductService(); sqlSelect = "ProductID,ProductName,ProductImgPath,RowFlag,CompID,ListNo"; sqlWhere = svProduct.CreateWhereAction(action, LogonCompID); sqlOrderBy = " ListNo ASC "; #region DoWhereCause sqlWhere += svProduct.CreateWhereCause(LogonCompID); if (!string.IsNullOrEmpty(ViewBag.Period)) { sqlWhere += SQLWhereDateTimeFromPeriod(ViewBag.Period, "ModifiedDate"); } #endregion var products = svProduct.SelectData <b2bProduct>(sqlSelect, sqlWhere, sqlOrderBy, (int)ViewBag.PageIndex, (int)ViewBag.PageSize); ViewBag.Products = products; ViewBag.TotalRow = svProduct.TotalRow; ViewBag.TotalPage = svProduct.TotalPage; }
// // GET: /Admin/ApproveProduct/ public void List_DoloadData(ProductAction action) { var svProduct = new ProductService(); string sqlSelect, sqlWhere, sqlOrderBy = ""; sqlSelect = "TOP 500 ProductID,ProductName,RowFlag,CompID,comprowflag,CompName,Remark,RowVersion,CateLV1,CateLV2,CateLV3,AdminCode,CompCode,CreatedBy,ModifiedBy,Modifieddate,CreatedDate,CategoryType "; sqlWhere = svProduct.CreateWhereAction(action) + " "; sqlOrderBy = " RowFlag DESC , CreatedDate DESC "; #region DoWhereCause sqlWhere += svProduct.CreateWhereCause(0, "", (int)ViewBag.PStatus); sqlWhere += svProduct.CreateWhereSearchBy(ViewBag.TextSearch, ViewBag.SearchType); if (!string.IsNullOrEmpty(ViewBag.Period)) { sqlWhere += SQLWhereDateTimeFromPeriod(ViewBag.Period, "CreatedDate"); } if (LogonServiceType == 15) { sqlWhere += " AND IsSME = 1"; } #endregion sqlWhere += " AND YEAR(Modifieddate) = YEAR(GETDATE())"; //var products = svProduct.SelectData<view_SearchProduct>(sqlSelect, sqlWhere, sqlOrderBy, (int)ViewBag.PageIndex, (int)ViewBag.PageSize); var sql = "SELECT " + sqlSelect + " FROM view_SearchProduct WHERE" + sqlWhere + " ORDER By " + sqlOrderBy; var listData = svProduct.qDB.ExecuteQuery <view_SearchProduct>(sql).ToList(); var products = listData.Skip(((int)ViewBag.PageIndex - 1) * (int)ViewBag.PageSize).Take((int)ViewBag.PageSize).ToList(); var test = (listData.Count() / (int)ViewBag.PageSize); ViewBag.Products = products; ViewBag.LogonCompID = LogonCompID; ViewBag.TotalRow = listData.Count(); ViewBag.TotalPage = (listData.Count() / (int)ViewBag.PageSize); }
public void List_DoloadBlogData(ProductAction action) { svArticle = new ArticleService(); string sqlSelect = "ArticleID, ArticleName, ImgPath, ShortDescription, CompID, ViewCount"; string sqlWhere = "IsDelete = 0 "; if ((int)ViewBag.CompID > 0) { sqlWhere += "AND (CompID = " + (int)ViewBag.CompID + ")"; } string sqlOrderBy = " ListNo ASC "; var emArticles = svArticle.SelectData <b2bArticle>(sqlSelect, sqlWhere, sqlOrderBy, (int)ViewBag.PageIndex, (int)ViewBag.PageSize); if (emArticles != null) { if (emArticles.Count() > 0) { ViewBag.emArticles = emArticles; ViewBag.TotalRow = svArticle.TotalRow; ViewBag.TotalPage = svArticle.TotalPage; var comp = svArticle.SelectData <b2bCompany>("CompID,CompName", "CompID = " + (int)ViewBag.CompID); ViewBag.WebCompName = comp[0].CompName; } else { ViewBag.emArticles = null; ViewBag.Message = res.Message_Center.lblNoresult; } } else { ViewBag.emArticles = null; ViewBag.Message = res.Message_Center.lblNoresult; } }
public JsonResult Get_Product(int Id) { return(Json(ProductAction.Find_By_Id(Id), JsonRequestBehavior.AllowGet)); }
public CommerceEvent(ProductAction productAction, Product[] products, TransactionAttributes transactionAttributes = null) { this.ProductAction = productAction; this.Products = products; this.TransactionAttributes = transactionAttributes; }
public ActionResult UpdateProduct(int Id, string Name, double Price) { ProductAction.Update_Product(Id, Name, Price); return(Redirect("~/Manager/ProductManager")); }
public ActionResult Delete_Product(int Id) { ProductAction.Delete_Product(Id); return(Redirect("~/Manager/ProductManager")); }
public ProductCommand(ProductModel product, ProductAction action) { this.Product = product; this.action = action; productService = new ProductService(); }
public virtual UpdateResult performProductAction(ProductAction productAction, Statement filterStatement) { object[] results = this.Invoke("performProductAction", new object[] { productAction, filterStatement }); return ((UpdateResult) (results[0])); }
public ActionResult Undelete_Product(int Id) { ProductAction.Restore_Product(Id); return(Redirect("~/Manager/ProductRestore")); }