public static void InsertProductInStore(ProductInStore dmo) { var query = new DQueryDom(new JoinAlias(typeof(ProductInStore))); query.Columns.Add(DQSelectColumn.Field("DeviceId")); query.Where.Conditions.Add(DQCondition.EQ("InStoreDate", dmo.InStoreDate)); var deviceIds = query.EExecuteList <string>(); if (deviceIds.Contains(dmo.DeviceId)) { return; } using (var context = new TransactionContext()) { foreach (var d in dmo.Details) { d.Price = 0; d.Money = 0; d.ProductionDate = GetProductPlanDate(d.ProductPlan_ID); } var bl = BIFactory.Create <IProductInStoreBL>(context); //dmo.BillState = 单据状态.已审核; dmo.IsHandsetSend = true; bl.Insert(dmo); if (new B3ButcheryConfig().DoCheckCreatedInStore.Value) { bl.Check(dmo); } context.Commit(); } }
public void setUp() { admin = new User(0, "admin", "123456", true, true); basket_admin = admin.Basket; user = new User(1, null, null, false, false); basket_user = user.Basket; store = new Store(-1, "store", 0, null, null); p1 = new Product(0, "first", "", "", 5000); p2 = new Product(1, "second", "", "", 5000); p3 = new Product(2, "third", "", "", 5000); p4 = new Product(3, "fourth", "", "", 5000); pis1 = new ProductInStore(10000000, store, p1); pis2 = new ProductInStore(10000000, store, p2); pis3 = new ProductInStore(10000000, store, p3); pis4 = new ProductInStore(10000000, store, p4); store.Products.Add(p1.Id, pis1); store.Products.Add(p2.Id, pis2); store.Products.Add(p3.Id, pis3); store.Products.Add(p4.Id, pis4); sys = new TradingSystem(null, null); sys.StoreCounter = 1; sys.ProductCounter = 4; sys.UserCounter = 2; sys.Stores.Add(store.Id, store); sys.Users.Add(admin.Id, admin); sys.Users.Add(user.Id, user); }
public void simpleViewUserHistory() { User aviad = us.startSession(); Assert.IsNotNull(aviad); int storeId = ss.createStore("abowim", zahi); Store store = StoreManagement.getInstance().getStore(storeId); Assert.IsNotNull(store); Assert.IsTrue(us.register(aviad, "aviad", "123456") > -1); Assert.IsTrue(us.login(aviad, "aviad", "123456") > -1); int pisId = ss.addProductInStore("cola", 3.2, 10, zahi, store.getStoreId(), "Drink"); ProductInStore pis = ProductManager.getInstance().getProductInStore(pisId); Assert.IsNotNull(pis); int saleId = ss.addSaleToStore(zahi, store.getStoreId(), pis.getProductInStoreId(), 1, 8, DateTime.Now.AddDays(10).ToString()); LinkedList <Sale> sales = ses.viewSalesByProductInStoreId(pis.getProductInStoreId()); Assert.IsTrue(sales.Count == 1); Sale sale = sales.First.Value; Assert.IsTrue(ses.addProductToCart(aviad, sale.SaleId, 2) > -1); LinkedList <UserCart> sc = ses.viewCart(aviad); Assert.IsTrue(sc.Count == 1); Assert.IsTrue(sc.First.Value.getSaleId() == saleId); Assert.IsTrue(ses.buyProducts(aviad, "1234", "")); LinkedList <Purchase> historyList = ss.viewUserHistory(admin, "aviad"); Assert.IsTrue(historyList.Count == 1); Assert.IsTrue(historyList.First.Value.ProductId == pis.getProduct().getProductId()); Assert.IsTrue(historyList.First.Value.Amount == 2); }
public void setUp() { store = new Store(2, "ZARA"); owner = new User(205600191, "Rotem", "r455!2@", false, false); owner.State = state.signedIn; ownerRole = new Owner(store, owner); owner.Roles.Add(owner.Id, ownerRole); store.Roles = new TreeNode <Role>(ownerRole); store.RolesDictionary.Add(owner.Id, new TreeNode <Role>(ownerRole)); manager = new User(203114469, "Noy", "!(ftR6", false, false); List <int> permissions = new List <int>(); permissions.Add(3); permissions.Add(4); permissions.Add(5); permissions.Add(6); managerRole = new Manager(store, manager, permissions); manager.Roles.Add(manager.Id, managerRole); store.Roles.AddChild(managerRole); store.RolesDictionary.Add(manager.Id, new TreeNode <Role>(managerRole)); user = new User(201119304, "Keren", "@rtY89", false, false); List <int> invalidPremissions = new List <int>(); invalidPremissions.Add(1); notPremittedManager = new User(202445691, "Adi", "*&112rY", false, false); notPremittedManagerRole = new Manager(store, notPremittedManager, invalidPremissions); notPremittedManager.Roles.Add(notPremittedManager.Id, notPremittedManagerRole); store.Roles.AddChild(notPremittedManagerRole); store.RolesDictionary.Add(notPremittedManager.Id, new TreeNode <Role>(notPremittedManagerRole)); p = new Product(2, "Skinny jeans", "Trouses", "Gray", 159); pis = new ProductInStore(30, store, p); store.Products.Add(p.Id, pis); }
private void CreateBtn_Click(object sender, EventArgs e) { string[] storeArray = StoreList.SelectedItem.ToString().Split(')'); string[] productArray = ProductList.SelectedItem.ToString().Split(')'); string[] customerArray = CustomerList.SelectedItem.ToString().Split(')'); int StoreId = Convert.ToInt32(storeArray[0]); int ProductId = Convert.ToInt32(productArray[0]); int customerId = Convert.ToInt32(productArray[0]); ProductInStore productInStore = new ProductInStore { ProductId = ProductId, StoreId = StoreId, Stock = Convert.ToInt32(PieeceNumber.Value) }; StockMovement stockMovement = new StockMovement { MemberNumber = customerId, Type = "Sell", Piece = Convert.ToInt32(PieeceNumber.Value), ProductId = ProductId, TotalPrice = decimal.Parse(TotalPriceTxt.Text), UnitPrice = decimal.Parse(UnitPriceTxt.Text), TransactionDate = DateTime.Now }; createMessage.CreateMessageBox(buyOrSellService.Sell(productInStore, stockMovement)); }
public string Sell(ProductInStore productInStore, StockMovement stockMovement) { result = validator.Validate(productInStore); result2 = validator2.Validate(stockMovement); if (result.IsValid && result2.IsValid) { ProductInStore productInStore1 = productInStoreDal.Get(p => p.ProductId == productInStore.ProductId && p.StoreId == productInStore.StoreId); productInStore1.Stock -= productInStore.Stock; productInStoreDal.Update(productInStore1); stockMovementDal.Add(stockMovement); JObject jsonObject = new JObject(); jsonObject.Add("Status", "success"); jsonObject.Add("ErrorMessage", "Ürün başarıyla satıldı."); JArray array = new JArray(); array.Add(jsonObject); return(JsonConvert.SerializeObject(array)); } else { if (!result.IsValid) { return(JsonConvert.SerializeObject(result.Errors)); } else { return(JsonConvert.SerializeObject(result2.Errors)); } } }
public void setUp() { discountPolicies = new List <DiscountPolicy>(); purchasePolicies = new List <PurchasePolicy>(); user = new User(1, "aviv", "123", false, false); store = new Store(0, "blabla"); Owner owner = new Owner(store, user); store.Roles.AddChild(owner); basket_user = user.Basket; admin = new User(0, "admin", "1234", true, false); basket_user = user.Basket; p1 = new Product(0, "first", "cat", "key", 80); p2 = new Product(1, "second", null, "", 3000); p3 = new Product(2, "third", null, "", 2000); p4 = new Product(3, "fourth", null, "", 5000); pis1 = new ProductInStore(10000000, store, p1); pis2 = new ProductInStore(10000000, store, p2); pis3 = new ProductInStore(10000000, store, p3); pis4 = new ProductInStore(10000000, store, p4); store.Products.Add(p1.Id, pis1); store.Products.Add(p2.Id, pis2); store.Products.Add(p3.Id, pis3); store.Products.Add(p4.Id, pis4); sys = new TradingSystem(null, null); sys.StoreCounter = 1; sys.ProductCounter = 4; sys.UserCounter = 2; sys.Stores.Add(store.Id, store); sys.Users.Add(admin.Id, admin); sys.Users.Add(user.Id, user); }
public static long?ProductInStoreSaveAndCheck(ProductInStore dto) { if (!BLContext.User.IsInRole("B3Butchery.成品入库.新建")) { return(0); } if (!BLContext.User.IsInRole("B3Butchery.成品入库.审核")) { return(-1); } using (var context = new TransactionContext()) { var bl = BIFactory.Create <IProductInStoreBL>(context.Session); var dmo = bl.Load(dto.ID); foreach (var detail in dmo.Details) { var fd = dto.Details.FirstOrDefault(x => x.ID == detail.ID); if (fd != null) { detail.Number = fd.Number; detail.SecondNumber = fd.Number * fd.Goods_SecondUnitRatio / fd.Goods_MainUnitRatio; } } bl.Update(dmo); bl.Check(dmo); context.Commit(); return(dmo.ID); } }
public IHttpActionResult PutProductInStore(int id, ProductInStore productInStore) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != productInStore.Id) { return(BadRequest()); } db.Entry(productInStore).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductInStoreExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void init() { CleanDB cDB = new CleanDB(); cDB.emptyDB(); ProductManager.restartInstance(); SalesManager.restartInstance(); StoreManagement.restartInstance(); UserManager.restartInstance(); UserCartsManager.restartInstance(); BuyHistoryManager.restartInstance(); CouponsManager.restartInstance(); DiscountsManager.restartInstance(); RaffleSalesManager.restartInstance(); StorePremissionsArchive.restartInstance(); us = userServices.getInstance(); ss = storeServices.getInstance(); zahi = us.startSession(); us.register(zahi, "zahi", "123456"); us.login(zahi, "zahi", "123456"); int storeid = ss.createStore("abowim", zahi); store = StoreManagement.getInstance().getStore(storeid); int c = ss.addProductInStore("cola", 3.2, 10, zahi, storeid, "Drinks"); cola = ProductManager.getInstance().getProductInStore(c); }
public IActionResult AddProduct(Guid storeId, ProductInStore model) { var store = _storeService.GetStoreIncludeProducts(storeId); var product = _productService.Get().FirstOrDefault(x => x.Code == model.Code); var productInStore = store.Products.FirstOrDefault(x => x.ProductId == product.Id); if (productInStore != null) { productInStore.Quantity = model.Quantity; } else { store.Products.Add(new ProductInStore { ProductId = product.Id, Code = product.Code, Quantity = model.Quantity, }); } _storeService.Update(store); return(Ok(model)); }
public void removeProductFromStoreWithManagerPermission() { ss.removeManagerPermission("removeProductFromStore", store.getStoreId(), "aviad", zahi); ProductInStore pis = ProductManager.getInstance().getProductInStore(ss.addProductInStore("cola", 10, 4, zahi, store.getStoreId(), "Drink")); ss.removeProductFromStore(store.getStoreId(), pis.getProductInStoreId(), aviad); Assert.AreEqual(1, store.getProductsInStore().Count); }
public void addDiscountWithManagerPermission() { ProductInStore pis = ProductManager.getInstance().getProductInStore(ss.addProductInStore("cola", 150, 100, zahi, store.getStoreId(), "Drink")); int saleId = ss.addSaleToStore(zahi, store.getStoreId(), pis.getProductInStoreId(), 1, 40, DateTime.Now.AddYears(1).ToString()); ss.removeManagerPermission("addDiscount", store.getStoreId(), aviad.getUserName(), zahi); Assert.AreEqual(0, DiscountsManager.getInstance().getAllDiscounts().Count); }
public void removePISWithManagerPremition() { zahiOwner.addManagerPermission(zahi, "removeProductFromStore", store, "aviad"); ProductInStore colaId = ProductManager.getInstance().getProductInStore(cola.productInStoreId); Assert.IsTrue(aviadManeger.removeProductFromStore(aviad, store, colaId) > -1); Assert.AreEqual(store.getAllSales().Count, 0); }
public void setUp() { admin = new User(0, "admin", "123456", true, true); basket_admin = admin.Basket; user = new User(1, null, null, false, false); basket_user = user.Basket; store = new Store(-1, "store"); p1 = new Product(0, "first", "", "", 5000); p2 = new Product(1, "second", "", "", 5000); p3 = new Product(2, "third", "", "", 5000); p4 = new Product(3, "fourth", "", "", 5000); pis1 = new ProductInStore(10000000, store, p1); pis2 = new ProductInStore(10000000, store, p2); pis3 = new ProductInStore(10000000, store, p3); pis4 = new ProductInStore(10000000, store, p4); store.Products.Add(p1.Id, pis1); store.Products.Add(p2.Id, pis2); store.Products.Add(p3.Id, pis3); store.Products.Add(p4.Id, pis4); sys = new TradingSystem(null, null); sys.StoreCounter = 1; sys.ProductCounter = 4; sys.UserCounter = 2; sys.Stores.Add(store.Id, store); sys.Users.Add(admin.Id, admin); sys.Users.Add(user.Id, user); Dictionary <int, KeyValuePair <ProductInStore, int> > discountProduct = new Dictionary <int, KeyValuePair <ProductInStore, int> >(); discountProduct.Add(p1.Id, new KeyValuePair <ProductInStore, int>(pis1, 0)); rd_min = new RevealedDiscount(sys.DiscountPolicyCounter++, 0.2, discountProduct, new DateTime(2222, 1, 1), DuplicatePolicy.WithMultiplication); rd_mid = new RevealedDiscount(sys.DiscountPolicyCounter++, 0.25, discountProduct, new DateTime(2222, 1, 1), DuplicatePolicy.WithMultiplication); rd_max = new RevealedDiscount(sys.DiscountPolicyCounter++, 0.3, discountProduct, new DateTime(2222, 1, 1), DuplicatePolicy.WithMultiplication); rd_mid_without = new RevealedDiscount(sys.DiscountPolicyCounter++, 0.35, discountProduct, new DateTime(2222, 1, 1), DuplicatePolicy.WithoutMultiplication); rd_max_without = new RevealedDiscount(sys.DiscountPolicyCounter++, 1, discountProduct, new DateTime(2222, 1, 1), DuplicatePolicy.WithoutMultiplication); Dictionary <int, KeyValuePair <ProductInStore, int> > relatedProduct = new Dictionary <int, KeyValuePair <ProductInStore, int> >(); relatedProduct.Add(p1.Id, new KeyValuePair <ProductInStore, int>(pis1, 2)); lc1 = new LeafCondition(relatedProduct, 0, 0, null, new DateTime(), DuplicatePolicy.WithMultiplication); relatedProduct = new Dictionary <int, KeyValuePair <ProductInStore, int> >(); relatedProduct.Add(p1.Id, new KeyValuePair <ProductInStore, int>(pis2, 1)); lc2 = new LeafCondition(relatedProduct, 0, 0, null, new DateTime(), DuplicatePolicy.WithMultiplication); Dictionary <int, ProductInStore> ProductPrecentage = new Dictionary <int, ProductInStore>(); ProductPrecentage.Add(pis1.Product.Id, pis1); ProductPrecentage.Add(pis2.Product.Id, pis2); lc = new LogicalCondition(0, 0.5, ProductPrecentage, new DateTime(2222, 1, 1), DuplicatePolicy.WithMultiplication, LogicalConnections.and); lc.addChild(0, lc1); lc.addChild(1, lc2); }
public void removeCouponWithManagerPermission() { ProductInStore pis = ProductManager.getInstance().getProductInStore(ss.addProductInStore("cola", 150, 100, zahi, store.getStoreId(), "Drink")); Boolean added = ss.addCouponDiscount(aviad, store, "coupon", pis, 10, DateTime.Now.AddYears(1).ToString()); Assert.AreEqual(true, added); ss.removeManagerPermission("removeCoupon", store.getStoreId(), aviad.getUserName(), zahi); Assert.AreEqual(false, ss.removeCoupon(store, aviad, "coupon")); }
public void removeProductInStore() { Store store = new Store(1, "halavi", null); Product milk = productArchive.addProduct("milk"); ProductInStore milkInStore = productArchive.addProductInStore(milk, store, 50, 50); Boolean check = productArchive.removeProductInStore(milkInStore.getProductInStoreId(), store.getStoreId()); Assert.IsTrue(check); }
public void getProductInStoreQuantity() { Store store = new Store(1, "halavi", null); Product milk = productArchive.addProduct("milk"); ProductInStore milkInStore = productArchive.addProductInStore(milk, store, 50, 50); int quantity = ProductManager.getInstance().getProductInStoreQuantity(milkInStore.getProductInStoreId()); Assert.AreEqual(quantity, milkInStore.getAmount()); }
public void AddSaleWithOwnerOfAnotherStore() { int storeid = ss.createStore("admin store", admin); Store store2 = StoreManagement.getInstance().getStore(storeid); int m = ss.addProductInStore("milk", 3.2, 10, admin, storeid, "Drinks"); ProductInStore milk = ProductManager.getInstance().getProductInStore(m); Assert.AreEqual(ss.addSaleToStore(admin, store.getStoreId(), milk.getProductInStoreId(), 1, 1, DateTime.Now.AddMonths(1).ToString()), -4);//-4 if don't have premition }
public void AddSaleWithProductNotInStore() { int storeid = ss.createStore("admin store", admin); Store store2 = StoreManagement.getInstance().getStore(storeid); int m = ss.addProductInStore("milk", 3.2, 10, admin, storeid, "Drinks"); ProductInStore milk = ProductManager.getInstance().getProductInStore(m); Assert.AreEqual(ss.addSaleToStore(itamar, store.getStoreId(), milk.getProductInStoreId(), 1, 1, DateTime.Now.AddMonths(1).ToString()), -13); //-13 product not in this store }
public void addSaleToStoreWithManagerPermission() { ProductInStore pis = ProductManager.getInstance().getProductInStore(ss.addProductInStore("cola", 10, 4, zahi, store.getStoreId(), "Drink")); ss.removeManagerPermission("addSaleToStore", store.getStoreId(), aviad.getUserName(), zahi); int saleId = ss.addSaleToStore(aviad, store.getStoreId(), pis.getProductInStoreId(), 1, 100, DateTime.Now.AddYears(1).ToString()); Assert.AreEqual(-4, saleId); //-4 dont have premition }
public void addExistingProductInStore() { Store store = new Store(1, "halavi", null); Product milk = productArchive.addProduct("milk"); ProductInStore breadInStore = productArchive.addProductInStore(milk, store, 50, 50); ProductInStore anotherBread = productArchive.addProductInStore(milk, store, 60, 60); Assert.AreEqual(anotherBread, null); }
public void AddProductWithNegativeAmount() { int storeid = ss.createStore("abowim", zahi); Store s = StoreManagement.getInstance().getStore(storeid); int p = ss.addProductInStore("cola", 3.2, -31, zahi, storeid, "Drinks"); ProductInStore pis = ProductManager.getInstance().getProductInStore(p); Assert.IsNull(pis); Assert.AreEqual(s.getProductsInStore().Count, 0); }
public Boolean addDiscount(ProductInStore p, int percentage, String dueDate, User session, Store s) { StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(false); } return(sR.addDiscount(session, p, percentage, dueDate)); }
public Boolean addCouponDiscount(User session, Store s, String couponId, ProductInStore p, int percentage, String dueDate) { StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(false); } return(sR.addNewCoupon(session, couponId, p, percentage, dueDate)); }
public Boolean removeDiscount(ProductInStore p, Store s, User session) { StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(false); } return(sR.removeDiscount(session, p)); }
private async Task SeedProductInStores() { var productInStore1 = new ProductInStore { Product = db.Products.Local.ElementAt(0), Store = db.Stores.Local.ElementAt(0), }; // Adding to database context await db.ProductInStores.AddRangeAsync(productInStore1); }
public void getExistingProductInStore() { Store store = new Store(1, "halavi", null); Product milk = productArchive.addProduct("milk"); ProductInStore breadInStore = productArchive.addProductInStore(milk, store, 50, 50); ProductInStore check = productArchive.getProductInStore(breadInStore.getProductInStoreId()); Assert.IsTrue(check != null); }
public void editProductInStoreWithManagerPermission() { ProductInStore pis = ProductManager.getInstance().getProductInStore(ss.addProductInStore("cola", 10, 4, zahi, store.getStoreId(), "Drink")); Assert.AreEqual(1, store.getProductsInStore().Count); ss.removeManagerPermission("editProductInStore", store.getStoreId(), "aviad", zahi); ss.editProductInStore(aviad, store.getStoreId(), pis.getProductInStoreId(), 13, 4.5); Assert.AreEqual(10, pis.getPrice()); Assert.AreEqual(4, pis.getAmount()); }
public IHttpActionResult GetProductInStore(int id) { ProductInStore productInStore = db.ProductInStores.Find(id); if (productInStore == null) { return(NotFound()); } return(Ok(productInStore)); }