public void Can_Connect_To_DataBase_By_ProductContext_Whitch_Inherits_From_DbContextBase() { using (var context = new ProductContext()) { Assert.IsNotNull(context); } }
protected override void DoEnd () { base.DoEnd (); ClearProducts(); context.Close(); context = null; }
public void Created_ProductContext_Is_Valid_Type() { using (var context = new ProductContext()) { Assert.AreSame(typeof(ProductContext), context.GetType()); } }
public void Should_Get_Product_By_Id_With_Given_Context() { var context = new ProductContext(); var repo = new ProductRepository(context); var product = repo.Get(1); Assert.IsNotNull(product); Assert.AreEqual(1,product.ProductId); }
public void Dispose() { if (_db != null) { _db.Dispose(); _db = null; } }
// // GET: /Home/ public ViewResult Index() { //return View(db.Products.ToList()); using (var db = new ProductContext()) { return View(db.Products.ToList());//does it } }
public void Should_Geted_Product_By_Same_Id_With_And_Without_Given_Context_Be_Equal() { var context = new ProductContext(); var repo = new ProductRepository(context); var product1 = repo.Get(1); var product2 = repo.Get(1); Assert.AreSame(product1,product2); }
public static DbContext GetContext(DBKey index) { string key = GetKey(index); DbContext dc = (ProductContext)HttpContext.Current.Items[key]; if(dc==null){ dc = new ProductContext(); HttpContext.Current.Items.Add(key,dc); } return dc; }
public void Should_Get_Product_By_Id() { var context = new ProductContext(); var repo = new ProductRepository(context); var logger = new EntLibLogger(null); //Assert.IsNotNull(product); //Assert.AreEqual(1,product.ProductId); var service = new ProductService(repo,logger); var product = service.GetProduct(316); Assert.IsNotNull(product); Assert.AreEqual("Blade", product.Name); }
public void Can_ReadWrite_Data_From_ProductTable_In_DataBase() { using (var context = new ProductContext()) { context.Products.Add(new Product()); var list = context.Products.ToList(); //var items = context.Products.Find() var item = context.Products.Find(316); Assert.AreEqual("Blade",item.Name); Assert.IsNotEmpty(list); Assert.IsNotNull(context); } }
public bool StartWork(System.Func<object> backgroundProc) { if (null == backgroundProc) { return false; } context = new ProductContext(backgroundProc); if (!base.StartWork(BkgProc, context)) { context = null; return false; } return true; }
public override void Up() { AddColumn("Products", "SupplierCode", c => c.String(maxLength: 128)); AddForeignKey("Products", "SupplierCode", "Suppliers", "SupplierCode"); CreateIndex("Products", "SupplierCode"); using (var db = new ProductContext()) { db.Suppliers.AddOrUpdate( s => s.SupplierCode, new Supplier { SupplierCode = "UNKNOWN", Name = "Unknown Supplier" } ); } Sql("UPDATE Products SET SupplierCode = 'UNKNOWN' WHERE SupplierCode is NULL"); }
public bool AddProduct(string ProductName, string ProductDesc, string ProductPrice, string ProductCategory, string ProductImagePath) { var myProduct = new Product(); myProduct.ProductName = ProductName; myProduct.Description = ProductDesc; myProduct.UnitPrice = Convert.ToDouble(ProductPrice); myProduct.ImagePath = ProductImagePath; myProduct.CategoryID = Convert.ToInt32(ProductCategory); using (ProductContext _db = new ProductContext()) { // Add product to DB. _db.Products.Add(myProduct); _db.SaveChanges(); } // Success. return true; }
/// <summary> /// 载入数据 /// </summary> /// <param name="info">BEProductDataInfo结构</param> private void LoadProductData(ProductData data) { this.m_id = data.id; this.HuoHao = data.huohao; this.DengJi_Id = data.dengji_id; this.MadePlace_Id = data.madeplace_id; this.PartName_Id = data.partname_id; this.SafeData_Id = data.safedata_id; this.StandardData_Id = data.standarddata_id; this.m_price = data.price; this.m_memo = data.memo; this.m_pwash = data.pwash == 1 ? true : false; this.m_tag_id = data.tag_id; this.m_wash_id = data.wash_id; this.m_lastamp = data.lastamp; this.m_pbad = data.pbad == 1 ? true : false; this.m_ptemplate = data.ptemplate == 1 ? true : false; this.m_wash_u = data.wash_u; this.m_template_data = data.template_data; this.Color_Id = (int)data.color_id; this.m_gyear = data.gyear; this.m_gmonth = data.gmonth; //加载EAN13信息 using (ProductContext ctx = new ProductContext()) { var ean13_data = from mater in ctx.BarcodeInfo where mater.product_id == this.m_id orderby mater.size_name select mater; foreach(var obj in ean13_data) { EAN13DataInfo info = new EAN13DataInfo(); info.Id = obj.id; info.SizeName = obj.size_name; info.BarcodeType = obj.barcode; info.Memo = obj.memo; this.m_ean13_data_list.Add(info); } } using (ProductContext ctx = new ProductContext()) { //洗唛宽度 this.m_wash_size = (from product in ctx.ProductData where product.id == this.m_id select product.WashPrintTemplate.daxiao).FirstOrDefault(); //处理成份信息 var materialData_entity = from mater in ctx.MaterialData where mater.product_id == this.m_id orderby mater.order_index select mater; foreach(var obj in materialData_entity) { MaterialDataInfo info = new MaterialDataInfo(); info.Id = obj.id; info.Type = obj.type; info.Sel = obj.sel; info.Memo = obj.memo; this.m_material_data_list.Add(info); } /*******************************************************/ //处理填充信息 var fill_entity = from fill in ctx.MaterialFill where fill.product_id == this.m_id orderby fill.size_name select fill; foreach(var obj in fill_entity) { UpdataMaterialFillList(obj.size_name, obj.fill); } this.MaterialFillInfo.material_type = (from fill in ctx.MaterialFill where fill.product_id == this.m_id select fill.type).FirstOrDefault(); //处理打印模板信息 } this.m_tagCODE93_filename = string.Format("{0}\\{1}", ConfigurationManager.AppSettings["Template"], GetTagFileName()); //this.m_wash_filename = string.Format("{0}\\{1}", ConfigurationManager.AppSettings["Template"], GetWashFileName()); this.m_wash_filename = string.Format("{0}\\{1}", ConfigurationManager.AppSettings["Template"],GetWashFileNameById(this.Wash_Id)); this.m_tagEAN13_filename = string.Format("{0}\\13{1}", ConfigurationManager.AppSettings["Template"], GetTagFileName()); }
/// <summary> /// 以产品货号构造 /// </summary> /// <param name="huohao">产品货号</param> public ProductObject(string huohao) { using (ProductContext ctx = new ProductContext()) { ProductData data = (from product in ctx.ProductData where product.huohao == huohao select product).FirstOrDefault(); if (data == null) this.HuoHao = huohao; else LoadProductData(data); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { NVPAPICaller payPalCaller = new NVPAPICaller(); string retMsg = ""; string token = ""; string PayerID = ""; NVPCodec decoder = new NVPCodec(); token = Session["token"].ToString(); bool ret = payPalCaller.GetCheckoutDetails(token, ref PayerID, ref decoder, ref retMsg); if (ret) { Session["payerId"] = PayerID; var myOrder = new Order(); myOrder.OrderDate = Convert.ToDateTime(decoder["TIMESTAMP"].ToString()); myOrder.Username = User.Identity.Name; myOrder.FirstName = decoder["FIRSTNAME"].ToString(); myOrder.LastName = decoder["LASTNAME"].ToString(); myOrder.Address = decoder["SHIPTOSTREET"].ToString(); myOrder.City = decoder["SHIPTOCITY"].ToString(); myOrder.State = decoder["SHIPTOSTATE"].ToString(); myOrder.PostalCode = decoder["SHIPTOZIP"].ToString(); myOrder.Country = decoder["SHIPTOCOUNTRYCODE"].ToString(); myOrder.Email = decoder["EMAIL"].ToString(); myOrder.Total = Convert.ToDecimal(decoder["AMT"].ToString()); // Verify total payment amount as set on CheckoutStart.aspx. try { decimal paymentAmountOnCheckout = Convert.ToDecimal(Session["payment_amt"].ToString()); decimal paymentAmoutFromPayPal = Convert.ToDecimal(decoder["AMT"].ToString()); if (paymentAmountOnCheckout != paymentAmoutFromPayPal) { Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } } catch (Exception) { Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } // Get DB context. ProductContext _db = new ProductContext(); // Add order to DB. _db.Orders.Add(myOrder); _db.SaveChanges(); // Get the shopping cart items and process them. using (WingtipToys.Logic.ShoppingCartActions usersShoppingCart = new WingtipToys.Logic.ShoppingCartActions()) { List<CartItem> myOrderList = usersShoppingCart.GetCartItems(); // Add OrderDetail information to the DB for each product purchased. for (int i = 0; i < myOrderList.Count; i++) { // Create a new OrderDetail object. var myOrderDetail = new OrderDetail(); myOrderDetail.OrderId = myOrder.OrderId; myOrderDetail.Username = User.Identity.Name; myOrderDetail.ProductId = myOrderList[i].ProductId; myOrderDetail.Quantity = myOrderList[i].Quantity; myOrderDetail.UnitPrice = myOrderList[i].Product.UnitPrice; // Add OrderDetail to DB. _db.OrderDetails.Add(myOrderDetail); _db.SaveChanges(); } // Set OrderId. Session["currentOrderId"] = myOrder.OrderId; // Display Order information. List<Order> orderList = new List<Order>(); orderList.Add(myOrder); ShipInfo.DataSource = orderList; ShipInfo.DataBind(); // Display OrderDetails. OrderItemList.DataSource = myOrderList; OrderItemList.DataBind(); } } else { Response.Redirect("CheckoutError.aspx?" + retMsg); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { NVPAPICaller payPalCaller = new NVPAPICaller(); string retMsg = ""; string token = ""; string PayerID = ""; NVPCodec decoder = new NVPCodec(); token = Session["token"].ToString(); bool ret = payPalCaller.GetCheckoutDetails(token, ref PayerID, ref decoder, ref retMsg); if (ret) { Session["payerId"] = PayerID; var myOrder = new Order(); myOrder.OrderDate = Convert.ToDateTime(decoder["TIMESTAMP"].ToString()); myOrder.Username = User.Identity.Name; myOrder.FirstName = decoder["FIRSTNAME"].ToString(); myOrder.LastName = decoder["LASTNAME"].ToString(); myOrder.Address = decoder["SHIPTOSTREET"].ToString(); myOrder.City = decoder["SHIPTOCITY"].ToString(); myOrder.State = decoder["SHIPTOSTATE"].ToString(); myOrder.PostalCode = decoder["SHIPTOZIP"].ToString(); myOrder.Country = decoder["SHIPTOCOUNTRYCODE"].ToString(); myOrder.Email = decoder["EMAIL"].ToString(); myOrder.Total = Convert.ToDecimal(decoder["AMT"].ToString()); // Verify total payment amount as set on CheckoutStart.aspx. try { decimal paymentAmountOnCheckout = Convert.ToDecimal(Session["payment_amt"].ToString()); decimal paymentAmoutFromPayPal = Convert.ToDecimal(decoder["AMT"].ToString()); if (paymentAmountOnCheckout != paymentAmoutFromPayPal) { Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } } catch (Exception) { Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } // Get DB context. ProductContext _db = new ProductContext(); // Add order to DB. _db.Orders.Add(myOrder); _db.SaveChanges(); // Get the shopping cart items and process them. using (YogaEssentials1.Logic.ShoppingCartActions usersShoppingCart = new YogaEssentials1.Logic.ShoppingCartActions()) { List <CartItem> myOrderList = usersShoppingCart.GetCartItems(); // Add OrderDetail information to the DB for each product purchased. for (int i = 0; i < myOrderList.Count; i++) { // Create a new OrderDetail object. var myOrderDetail = new OrderDetail(); myOrderDetail.OrderId = myOrder.OrderId; myOrderDetail.Username = User.Identity.Name; myOrderDetail.ProductId = myOrderList[i].ProductId; myOrderDetail.Quantity = myOrderList[i].Quantity; myOrderDetail.UnitPrice = myOrderList[i].Product.UnitPrice; // Add OrderDetail to DB. _db.OrderDetails.Add(myOrderDetail); _db.SaveChanges(); } // Set OrderId. Session["currentOrderId"] = myOrder.OrderId; // Display Order information. List <Order> orderList = new List <Order>(); orderList.Add(myOrder); ShipInfo.DataSource = orderList; ShipInfo.DataBind(); // Display OrderDetails. OrderItemList.DataSource = myOrderList; OrderItemList.DataBind(); } } else { Response.Redirect("CheckoutError.aspx?" + retMsg); } } }
public ProductsController(ProductContext context, IDistributedCache cache) { _context = context; _cache = cache; }
public void UpdateShoppingCartDatabase(String cartId, ShoppingCartUpdates[] CartItemUpdates) { using (var db = new ProductContext()) { try { int CartItemCount = CartItemUpdates.Count(); List<CartItem> myCart = GetCartItems(); foreach (var cartItem in myCart) { // Iterate through all rows within shopping cart list for (int i = 0; i < CartItemCount; i++) { if (cartItem.Product.ProductID == CartItemUpdates[i].ProductId) { if (CartItemUpdates[i].PurchaseQuantity < 1 || CartItemUpdates[i].RemoveItem == true) { RemoveItem(cartId, cartItem.ProductId); } else { UpdateItem(cartId, cartItem.ProductId, CartItemUpdates[i].PurchaseQuantity); } } } } } catch (Exception exp) { throw new Exception("ERROR: Unable to Update Cart Database - " + exp.Message.ToString(), exp); } } }
public int GetWashFileNameId() { string file = this.GetWashFileName(); using (ProductContext ctx = new ProductContext()) { return (from wash in ctx.WashPrintTemplate where wash.file_name == file select wash.id).FirstOrDefault(); } }
public UsersController(ProductContext context) { _context = context; }
public ProductsController(ProductContext context) { _context = context; }
public PostProductCommandHandler(ProductContext context) { _context = context; }
public ProductRespositoryImpl(ProductContext _productContext) { productContext = _productContext; }
// GET: /<controller>/ public IActionResult Index() { ProductContext context = HttpContext.RequestServices.GetService(typeof(Test_scandiweb.Model.ProductContext)) as ProductContext; return(View(context.GetAllProducts())); }
public ProductService(ProductContext db) { _db = db ?? throw new ArgumentNullException(nameof(db)); }
public CartController(ProductContext context, IHttpContextAccessor httpContext) { _context = context; _httpContext = httpContext; }
/// <summary> /// 生成条型码 /// </summary> /// <param name="size_name">规格</param> /// <returns>条型码字符串</returns> public string BuildBarcode(string size_name) { using (ProductContext ctx = new ProductContext()) { string barcodePrefix = (from entity in ctx.PartName where entity.id == this.m_partname_id select entity.barcode).FirstOrDefault(); return string.Format("{0}{1}{2}", barcodePrefix, this.m_huohao, size_name); } }
public string GetWashFileName() { int materialdata_count = 0; if(m_wash_u > 0) { using (ProductContext ctx = new ProductContext()) { WashPrintTemplate wash_info = (from wash in ctx.WashPrintTemplate where wash.id == this.m_wash_u select wash).FirstOrDefault(); return wash_info.file_name; } } if (this.m_huohao.Substring(0, 1) == "L") { return "WashG.btw"; } if (this.m_huohao.Substring(0,1) == "W") { return "WashW.btw"; } foreach (var obj in this.m_material_data_list) { if (obj.Sel) ++materialdata_count; } int row = materialdata_count + (string.IsNullOrEmpty(this.MaterialFillInfo.material_type) ? 0 : 1); string str_class = this.m_huohao.Substring(0, 1); string file_name = string.Empty; using (ProductContext ctx = new ProductContext()) { IQueryable<WashPrintTemplate> wash_info = null; if(this.m_huohao.Substring(0,1) == "S") { int count = Regex.Matches(this.m_huohao, "-").Count; if(count == 1) { wash_info = from wash in ctx.WashPrintTemplate where wash.type.IndexOf(str_class) >= 0 && wash.daxiao == "7cm" select wash; } else { wash_info = from wash in ctx.WashPrintTemplate where wash.type.IndexOf(str_class) >= 0 && wash.daxiao == "4cm" select wash; } } else { wash_info = from wash in ctx.WashPrintTemplate where wash.type.IndexOf(str_class) >= 0 select wash; } foreach(var wash in wash_info) { if(wash.file_name.Substring(5,1) == row.ToString()) { file_name = wash.file_name; break; } } } if(this.m_ptemplate) { file_name = string.Format("T{0}", file_name); } return file_name; }
public ProductRepository(ProductContext db) { _db = db ?? throw new ArgumentNullException(nameof(db)); }
public void RemoveItem(string removeCartID, int removeProductID) { using (var _db = new ProductContext()) { try { var myItem = (from c in _db.ShoppingCartItems where c.CartId == removeCartID && c.Product.ProductID == removeProductID select c).FirstOrDefault(); if (myItem != null) { // Remove Item. _db.ShoppingCartItems.Remove(myItem); _db.SaveChanges(); } } catch (Exception exp) { throw new Exception("ERROR: Unable to Remove Cart Item - " + exp.Message.ToString(), exp); } } }
public HomeController(IMapper mapper, IProductRepository repository, ProductContext context) { _mapper = mapper; _repository = repository; _context = context; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Verify user has completed the checkout process. if ((string)Session["userCheckoutCompleted"] != "true") { Session["userCheckoutCompleted"] = string.Empty; Response.Redirect("CheckoutError.aspx?" + "Desc=Unvalidated%20Checkout."); } NVPAPICaller payPalCaller = new NVPAPICaller(); string retMsg = ""; string token = ""; string finalPaymentAmount = ""; string PayerID = ""; NVPCodec decoder = new NVPCodec(); token = Session["token"].ToString(); PayerID = Session["payerId"].ToString(); finalPaymentAmount = Session["payment_amt"].ToString(); bool ret = payPalCaller.DoCheckoutPayment(finalPaymentAmount, token, PayerID, ref decoder, ref retMsg); if (ret) { // Retrieve PayPal confirmation value. string PaymentConfirmation = decoder["PAYMENTINFO_0_TRANSACTIONID"].ToString(); TransactionId.Text = PaymentConfirmation; ProductContext _db = new ProductContext(); // Get the current order id. int currentOrderId = -1; if (Session["currentOrderId"] != string.Empty) { currentOrderId = Convert.ToInt32(Session["currentOrderID"]); } Order myCurrentOrder; if (currentOrderId >= 0) { // Get the order based on order id. myCurrentOrder = _db.Orders.Single(o => o.OrderId == currentOrderId); // Update the order to reflect payment has been completed. myCurrentOrder.PaymentTransactionId = PaymentConfirmation; // Save to DB. _db.SaveChanges(); } // Clear shopping cart. using (WingtipToys.Logic.ShoppingCartActions usersShoppingCart = new WingtipToys.Logic.ShoppingCartActions()) { usersShoppingCart.EmptyCart(); } // Clear order id. Session["currentOrderId"] = string.Empty; } else { Response.Redirect("CheckoutError.aspx?" + retMsg); } } }
protected GenericRepository(ProductContext aContext) { Context = aContext; }
public _productRepository(ProductContext dbContext) { _dbContext = dbContext; }
public ProductsController(ProductContext context, IHostingEnvironment hostingEnvironment) { _context = context; _environment = hostingEnvironment; }
public ProductRepository(ProductContext context) { _context = context; }
public ProductsEFController(ProductContext context, IMemoryCache memoryCache) { _context = context; _cache = memoryCache; }
/// <summary> /// 保存记录 /// </summary> /// <returns></returns> public SaveResult Save() { SaveResult result = new SaveResult(); //save new if(this.m_id == 0) { if(this.m_huohao.Trim() == string.Empty) { result.Code = CodeType.Error; result.Message = "[产品货号]不能为空或输入的不合法,无法保存!"; return result; } if (CheckProductHuoHaoExist(this.m_huohao.Trim())) { result.Code = CodeType.Error; result.Message = "[产品货号]重复,无法保存!"; return result; } if(this.m_partname_id == 0) { result.Code = CodeType.Error; result.Message = "[产品种类]不能为空,无法保存!"; return result; } if(this.m_dengji_id == 0) { result.Code = CodeType.Error; result.Message = "[产品等级]不能为空,无法保存!"; return result; } if(this.m_madeplace_id == 0) { result.Code = CodeType.Error; result.Message = "[产品产地]不能为空,无法保存!"; return result; } if(this.m_price == 0) { result.Code = CodeType.Error; result.Message = "[产品价格]不能为空,无法保存!"; return result; } if(this.m_safedata_id == 0) { result.Code = CodeType.Error; result.Message = "[安全标准]不能为空,无法保存!"; return result; } if(this.m_standarddata_id == 0) { result.Code = CodeType.Error; result.Message = "[执行标准]不能为空,无法保存!"; return result; } if(this.m_material_data_list.Count == 0) { result.Code = CodeType.Error; result.Message = "[面料成份信息列表]不能为空,无法保存!"; return result; } //当填充材质不为空时处理填充数据 if(!string.IsNullOrEmpty(this.MaterialFillInfo.material_type)) { foreach(MaterialFillInfoObject.MaterialFillData data in this.MaterialFillInfo.m_material_fill_list) { if(data.Fill == "0") { result.Code = CodeType.Error; result.Message = "填充规则数据制定不完整,请重新制定!"; return result; } } } ProductData info = new ProductData(); info.huohao = this.m_huohao; info.partname_id = this.m_partname_id; info.dengji_id = this.m_dengji_id; info.madeplace_id = this.m_madeplace_id; info.price = this.m_price; info.safedata_id = this.m_safedata_id; info.standarddata_id = this.m_standarddata_id; info.pwash = this.m_pwash == true ? 1:0; info.pbad = this.m_pbad == true ? 1:0; info.tag_id = this.GetTagFileNameId(); info.memo = this.m_memo; info.wash_id = this.GetWashFileNameId(); info.color_id = this.m_color_id; info.gyear = this.m_gyear; info.gmonth = this.m_gmonth; info.lastamp = System.Guid.NewGuid(); if(this.m_ptemplate) { info.ptemplate = 1; info.template_data = this.m_template_data; } if(info.tag_id == 0) { result.Code = CodeType.Error; result.Message = "系统未能找到对应的吊牌模板文件,保存无法继续!"; return result; } if(info.wash_id == 0) { if (this.m_partname_id == 21) info.wash_id = 1; else { result.Code = CodeType.Error; result.Message = "系统未能找到对应的洗唛模板文件,保存无法继续!"; return result; } } using (ProductContext ctx = new ProductContext()) { ctx.ProductData.Add(info); if(ctx.SaveChanges() == 0) { result.Code = CodeType.Error; result.Message = "产品基本信息保存失败"; return result; } } using (ProductContext ctx = new ProductContext()) { this.m_id = (from product in ctx.ProductData where product.huohao == this.m_huohao select product.id).FirstOrDefault(); } int index = 1; foreach(MaterialDataInfo ob in this.m_material_data_list) { using (ProductContext ctx = new ProductContext()) { MaterialData entity = new MaterialData(); entity.product_id = this.m_id; entity.sel = ob.Sel; entity.type = ob.Type; entity.order_index = index++; entity.memo = ob.Memo; entity.lastamp = System.Guid.NewGuid(); ctx.MaterialData.Add(entity); ctx.SaveChanges(); } } if(!string.IsNullOrEmpty(this.MaterialFillInfo.material_type)) { foreach(MaterialFillInfoObject.MaterialFillData fill in this.MaterialFillInfo.m_material_fill_list) { using (ProductContext ctx = new ProductContext()) { MaterialFill entity = new MaterialFill(); entity.product_id = this.m_id; entity.size_name = fill.SizeName; entity.type = this.MaterialFillInfo.material_type; entity.fill = fill.Fill; entity.lastamp = System.Guid.NewGuid(); ctx.MaterialFill.Add(entity); ctx.SaveChanges(); } } } result.Code = CodeType.Ok; result.Message = "保存成功!"; return result; } //Edit Save if(this.m_id > 0) { if (this.m_huohao.Trim() == string.Empty) { result.Code = CodeType.Error; result.Message = "[产品货号]不能为空或输入的不合法,无法保存!"; return result; } using (ProductContext ctx = new ProductContext()) { int count = (from product in ctx.ProductData where product.id == this.m_id && product.huohao == this.m_huohao select product).Count(); if(count > 1) { result.Code = CodeType.Error; result.Message = "[产品货号]重复,无法保存!"; return result; } } if (this.m_price == 0) { result.Code = CodeType.Error; result.Message = "[产品价格]不能为空,无法保存!"; return result; } if (this.m_safedata_id == 0) { result.Code = CodeType.Error; result.Message = "[安全标准]不能为空,无法保存!"; return result; } if (this.m_standarddata_id == 0) { result.Code = CodeType.Error; result.Message = "[执行标准]不能为空,无法保存!"; return result; } if (this.m_material_data_list.Count == 0) { result.Code = CodeType.Error; result.Message = "[面料成份信息列表]不能为空,无法保存!"; return result; } //当填充材质不为空时处理填充数据 if (!string.IsNullOrEmpty(this.MaterialFillInfo.material_type)) { foreach(MaterialFillInfoObject.MaterialFillData data in this.MaterialFillInfo.m_material_fill_list) { if(data.Fill == "0") { result.Code = CodeType.Error; result.Message = "填充规则数据制定不完整,请重新制定!"; return result; } } } using (ProductContext ctx = new ProductContext()) { System.Guid entity_lastamp = (from product in ctx.ProductData where product.id == this.m_id select product.lastamp).FirstOrDefault(); if(entity_lastamp != this.m_lastamp) { result.Code = CodeType.Error; result.Message = "当前编辑的记录已经变更,无法保存!"; return result; } } using (ProductContext ctx = new ProductContext()) { ProductData info = (from entity in ctx.ProductData where entity.id == this.m_id select entity).FirstOrDefault(); info.huohao = this.m_huohao; info.partname_id = this.m_partname_id; info.dengji_id = this.m_dengji_id; info.madeplace_id = this.m_madeplace_id; info.price = this.m_price; info.safedata_id = this.m_safedata_id; info.standarddata_id = this.m_standarddata_id; info.pwash = this.m_pwash == true ? 1:0; info.pbad = this.m_pbad == true ?1:0; info.memo = this.m_memo; info.tag_id = this.GetTagFileNameId(); info.wash_id = this.GetWashFileNameId(); info.color_id = this.m_color_id; info.gyear = this.m_gyear; info.gmonth = this.m_gmonth; info.lastamp = System.Guid.NewGuid(); if (this.m_ptemplate) { info.ptemplate = 1; info.template_data = this.m_template_data; } if (info.tag_id == 0) { result.Code = CodeType.Error; result.Message = "系统未能找到对应的吊牌模板文件,保存无法继续!"; return result; } if (info.wash_id == 0 ) { if(this.m_partname_id == 21) { info.wash_id = 1; } else { result.Code = CodeType.Error; result.Message = "系统未能找到对应的洗唛模板文件,保存无法继续!"; return result; } } if (ctx.SaveChanges() == 0) { result.Code = CodeType.Error; result.Message = "产品基本信息保存失败"; return result; } } //保存成份信息 using (ProductContext ctx = new ProductContext()) { var mi = from entity in ctx.MaterialData where entity.product_id == this.m_id select entity; foreach(var obj in mi) { ctx.MaterialData.Remove(obj); } ctx.SaveChanges(); } int index = 1; foreach (MaterialDataInfo ob in this.m_material_data_list) { using (ProductContext ctx = new ProductContext()) { MaterialData entity = new MaterialData(); entity.product_id = this.m_id; entity.sel = ob.Sel; entity.type = ob.Type; entity.order_index = index++; entity.memo = ob.Memo; entity.lastamp = System.Guid.NewGuid(); ctx.MaterialData.Add(entity); ctx.SaveChanges(); } } //////////////////////////////////////////////////////// using (ProductContext ctx = new ProductContext()) { var mi = from entity in ctx.MaterialFill where entity.product_id == this.m_id select entity; foreach (var obj in mi) { ctx.MaterialFill.Remove(obj); } ctx.SaveChanges(); } if (!string.IsNullOrEmpty(this.MaterialFillInfo.material_type)) { foreach (MaterialFillInfoObject.MaterialFillData fill in this.MaterialFillInfo.m_material_fill_list) { using (ProductContext ctx = new ProductContext()) { MaterialFill entity = new MaterialFill(); entity.product_id = this.m_id; entity.size_name = fill.SizeName; entity.type = this.MaterialFillInfo.material_type; entity.fill = fill.Fill; entity.lastamp = System.Guid.NewGuid(); ctx.MaterialFill.Add(entity); ctx.SaveChanges(); } } } result.Code = CodeType.Ok; result.Message = "保存成功!"; return result; } return result; }
public ValuesController(ProductContext context) { _context = context; }
public void SaveEAN13Info() { using (ProductContext ctx = new ProductContext()) { var data1 = from entity in ctx.BarcodeInfo where entity.product_id == this.m_id select entity; foreach ( var obj in data1) { ctx.BarcodeInfo.Remove(obj); } ctx.SaveChanges(); } foreach(EAN13DataInfo info in this.m_ean13_data_list ) { using (ProductContext ctx = new ProductContext()) { BarcodeInfo entity = new BarcodeInfo(); entity.product_id = this.m_id; entity.size_name = info.SizeName; entity.barcode = info.BarcodeType; entity.memo = info.Memo; entity.lastamp = System.Guid.NewGuid(); ctx.BarcodeInfo.Add(entity); ctx.SaveChanges(); } } }
public DeleteProductCommandHandler(ProductContext context) { _context = context; }
public static bool CheckProductHuoHaoExist(string huohao) { using (ProductContext ctx = new ProductContext()) { int count = (from product in ctx.ProductData where product.huohao == huohao select product).Count(); if (count > 0) return true; else return false; } }
public StoreController() { db = new ProductContext(); }
public int GetTagFileNameId() { string file = this.GetTagFileName(); using (ProductContext ctx = new ProductContext()) { return (from tag in ctx.TagPrintTemplate where tag.file_name == file select tag.id).FirstOrDefault(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Verify user has completed the checkout process. if ((string)Session["userCheckoutCompleted"] != "true") { Session["userCheckoutCompleted"] = string.Empty; Response.Redirect("CheckoutError.aspx?Desc=Unvalidated%20Checkout."); } NVPAPICaller payPalCaller = new NVPAPICaller(); string retMsg = string.Empty; string token = Session["token"].ToString(); string finalPaymentAmount = Session["payment_amt"].ToString(); string PayerID = Session["payerId"].ToString(); NVPCodec decoder = new NVPCodec(); bool ret = payPalCaller.DoCheckoutPayment(finalPaymentAmount, token, PayerID, ref decoder, ref retMsg); if (ret) { // Retrieve PayPal confirmation value. string PaymentConfirmation = decoder["PAYMENTINFO_0_TRANSACTIONID"].ToString(); TransactionId.Text = PaymentConfirmation; ProductContext _db = new ProductContext(); // Get the current order id. int currentOrderId = -1; try { currentOrderId = (int)Session["currentOrderId"]; } catch (InvalidCastException) { Response.Redirect("~/Default.aspx"); } Order myCurrentOrder; if (currentOrderId >= 0) { // Get the order based on order id. myCurrentOrder = _db.Orders.Single(o => o.OrderId == currentOrderId); // Update the order to reflect payment has been completed. myCurrentOrder.PaymentTransactionId = PaymentConfirmation; // Save to DB. _db.SaveChanges(); } // Clear shopping cart. using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { usersShoppingCart.EmptyCart(); } // Clear order id. Session["currentOrderId"] = string.Empty; } else { Response.Redirect("CheckoutError.aspx?" + retMsg); } } }
public string GetWashFileNameById(int id) { using(ProductContext ctx = new ProductContext()) { return ( from wash in ctx.WashPrintTemplate where wash.id == id select wash.file_name).FirstOrDefault(); } }
/// <summary> /// 以产品ID号构造 /// </summary> /// <param name="id">ID号</param> public ProductObject(int id) { using (ProductContext ctx = new ProductContext()) { ProductData data = (from product in ctx.ProductData where product.id == id select product).FirstOrDefault(); if(data != null) LoadProductData(data); } }
public DiagnosticsModel(ProductContext context) { _context = context; }
public void UpdateItem(string updateCartID, int updateProductID, int quantity) { using (var _db = new ProductContext()) { try { var myItem = (from c in _db.ShoppingCartItems where c.CartId == updateCartID && c.Product.ProductID == updateProductID select c).FirstOrDefault(); if (myItem != null) { myItem.Quantity = quantity; _db.SaveChanges(); } } catch (Exception exp) { throw new Exception("ERROR: Unable to Update Cart Item - " + exp.Message.ToString(), exp); } } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, ProductContext context) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); DbInitialize.Initialize(context); }
public EFStockRepository(ProductContext context) : base(context) { }
public DeleteOrderModel(ProductContext context, UserManager <TroydonFitnessWebsiteUser> userManager) : base(userManager) { _context = context; }
public IngredientRepository(ProductContext productContext) : base(productContext) { }
public AdminController(ProductContext context, IHostingEnvironment hostingEnvironment) { _context = context; _hostingEnvironment = hostingEnvironment; }
public IndexModel(ILogger <IndexModel> logger, ProductContext context) { _logger = logger; _dbContext = context; }
public UnitOfWork(ProductContext productContext) { _db = productContext; }
// Dependency injection public ProductController(ProductContext context) { this._context = context; }
public override EFRepositoryBase <Ingredient> GetRepository(ProductContext context) { return(new EFIngredientRepository(context)); }