public void ShouldReturnOnlyOneBackOrderableInformationIfDuplicatedProductIdsPassed() { // Arrange var orderableInfo = new OrderableInformation { Product = new InventoryProduct { ProductId = "1001" }, Status = StockStatus.InStock }; var invProduct1 = new InventoryProduct { ProductId = "1001" }; this._serviceProvider .GetBackOrderableInformation(Arg.Is <GetBackOrderableInformationRequest>(r => r.Shop.Name == "shopname" && r.Products.Contains(invProduct1) && r.Products.Count() == 1)) .ReturnsForAnyArgs(new GetBackOrderableInformationResult { OrderableInformation = new List <OrderableInformation> { orderableInfo } }); // Act var orderableInfos = this._inventoryService.GetBackOrderableInformation("shopname", new List <string> { "1001", "1001" }, string.Empty, string.Empty); // Assert orderableInfos.Count.Should().Be(1); orderableInfos.FirstOrDefault().ShouldBeEquivalentTo(orderableInfo); }
/// <summary> /// Visitors the sign up for stock notification. /// </summary> /// <param name="storefront">The storefront.</param> /// <param name="model">The model.</param> /// <param name="location">The location.</param> /// <returns> /// The manager response which returns success flag in the Result. /// </returns> public virtual ManagerResponse <VisitorSignUpForStockNotificationResult, bool> VisitorSignupForStockNotification([NotNull] CommerceStorefront storefront, SignUpForNotificationInputModel model, string location) { Assert.ArgumentNotNull(storefront, "storefront"); Assert.ArgumentNotNull(model, "model"); Assert.ArgumentNotNullOrEmpty(model.ProductId, "model.ProductId"); Assert.ArgumentNotNullOrEmpty(model.Email, "model.Email"); var visitorId = this.ContactFactory.GetContact(); var builder = new CommerceInventoryProductBuilder(); InventoryProduct inventoryProduct = builder.CreateInventoryProduct(model.ProductId); if (string.IsNullOrEmpty(model.VariantId)) { ((CommerceInventoryProduct)inventoryProduct).VariantId = model.VariantId; } DateTime interestDate; var isDate = DateTime.TryParse(model.InterestDate, out interestDate); var request = new VisitorSignUpForStockNotificationRequest(storefront.ShopName, visitorId, model.Email, inventoryProduct) { Location = location }; if (isDate) { request.InterestDate = interestDate; } var result = this.InventoryServiceProvider.VisitorSignUpForStockNotification(request); Helpers.LogSystemMessages(result.SystemMessages, result); return(new ManagerResponse <VisitorSignUpForStockNotificationResult, bool>(result, result.Success)); }
public ActionResult discount([Bind(Include = "productId, brandId, brandName, productName, productDescription, Image, categoryId, SupplierId, quantityOnHand, minimumStock, unitPrice, DiscountPrice, totalPrice, prevUnitPrice, quantityToOrder, onPromotion, status, isOrdered, onOrderednum, numRatings")] InventoryProduct inventoryProduct, HttpPostedFileBase upload) { if (ModelState.IsValid) { if (inventoryProduct.onPromotion == true && inventoryProduct.DiscountPrice > 0) { inventoryProduct.DiscountPrice = (inventoryProduct.DiscountPrice / 100) * inventoryProduct.unitPrice; inventoryProduct.unitPrice = inventoryProduct.unitPrice - inventoryProduct.DiscountPrice; } else if (inventoryProduct.onPromotion == false) { inventoryProduct.unitPrice = inventoryProduct.unitPrice + inventoryProduct.DiscountPrice; } if (upload != null && upload.ContentLength > 0) { using (var reader = new System.IO.BinaryReader(upload.InputStream)) { inventoryProduct.Image = reader.ReadBytes(upload.ContentLength); if (inventoryProduct.Image == null) { return(View(inventoryProduct)); } } } db.Entry(inventoryProduct).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SupplierId = new SelectList(db.Suppliers, "supplierid", "supplierName", inventoryProduct.SupplierId); return(View(inventoryProduct)); }
public async Task <bool> Add(InventoryProductDTO request) { var product = await DbContext.Products.SingleOrDefaultAsync(x => x.Id == request.ProductId); var inventory = await DbContext.Inventories.SingleOrDefaultAsync(x => x.Id == request.InventoryId); if (product is null) { throw new AppException("Product not found"); } if (inventory is null) { throw new AppException("Product not found"); } var inventoryProduct = new InventoryProduct() { Quantity = request.Quantity, Inventory = inventory, Product = product }; await DbContext.InventoryProducts.AddAsync(inventoryProduct); await DbContext.SaveChangesAsync(); return(true); }
protected override void beforeEach() { Given = new TaskViewModel { Product = "3_Chemicals", Task = ObjectMother.ValidTask("raif"), }; _field = ObjectMother.ValidField("raif"); _equipment1 = ObjectMother.ValidEquipment("raif").WithEntityId(6); _equipment2 = ObjectMother.ValidEquipment("poop").WithEntityId(7); _equipment3 = ObjectMother.ValidEquipment("crap").WithEntityId(8); repo = MockFor <IRepository>(); repo.Stub(x => x.Find <Field>(1)).Return(_field); _validInventoryChemical = ObjectMother.ValidInventoryProductChemical("lsd").WithEntityId(3); repo.Stub(x => x.Find <InventoryProduct>(3)).Return(_validInventoryChemical); _employee1 = ObjectMother.ValidEmployee("raif"); _employee2 = ObjectMother.ValidEmployee("Amahl"); _employee3 = ObjectMother.ValidEmployee("Ramsay"); repo.Stub(x => x.Find <Employee>(1)).Return(_employee1); repo.Stub(x => x.Find <Employee>(2)).Return(_employee2); repo.Stub(x => x.Find <Employee>(3)).Return(_employee3); repo.Stub(x => x.Find <Equipment>(6)).Return(_equipment1); repo.Stub(x => x.Find <Equipment>(7)).Return(_equipment2); repo.Stub(x => x.Find <Equipment>(8)).Return(_equipment3); _crudManager = MockRepository.GenerateMock <ICrudManager>(); _crudManager.Expect(x => x.Finish()).Return(new Notification()); _saveEntityService = MockFor <ISaveEntityService>(); _sesCatcher = _saveEntityService.CaptureArgumentsFor(x => x.ProcessSave(new Task(), null), x => x.Return(_crudManager)); }
public ResultOperation Update(InventoryProduct inventoryProduct) { return(SurroundWithTryCatch(() => { string error = string.Empty; ProductEntry entry = DB.ProductEntries.Include("SaleItems") .FirstOrDefault(r => r.Id == inventoryProduct.Id); if (entry == null) { error = "Inventory Item was not found."; } else if (entry.QuantityAvailable == 0 && entry.QuantityBought > inventoryProduct.Qtd) { error = $"This product has sold {entry.QuantityBought } unities. You must specify in quantity bought a number higher than it"; } else { entry.PurchaseDate = inventoryProduct.DatePurchase; entry.UnitPrice = inventoryProduct.Price; entry.QuantityAvailable += (inventoryProduct.Qtd - entry.QuantityBought); entry.QuantityBought = inventoryProduct.Qtd; entry.UnitPriceAcquisition = inventoryProduct.PriceAcquisition; DB.SaveChanges(); } return error; })); }
public void ShouldReturnOnlyOneStockInformationIfDuplicatedProductIdsPassed() { // Arrange var stockInfo = new StockInformation { Product = new InventoryProduct { ProductId = "1001" }, Status = StockStatus.InStock, AvailabilityDate = new DateTime(2014, 3, 12) }; var invProduct1 = new InventoryProduct { ProductId = "1001" }; this._serviceProvider .GetStockInformation(Arg.Is <GetStockInformationRequest>(r => r.Shop.Name == "shopname" && r.Products.Contains(invProduct1) && r.Products.Count() == 1 && r.DetailsLevel == StockDetailsLevel.All)) .ReturnsForAnyArgs(new GetStockInformationResult { StockInformation = new List <StockInformation> { stockInfo } }); // Act var stockInfos = this._inventoryService.GetStockInformation("shopname", new List <string> { "1001", "1001" }, StockDetailsLevel.All, string.Empty, string.Empty); // Assert stockInfos.Count.Should().Be(1); stockInfos.FirstOrDefault().ShouldBeEquivalentTo(stockInfo); }
public ActionResult DeleteConfirmed(int id) { InventoryProduct inventoryProduct = db.Products.Find(id); db.Products.Remove(inventoryProduct); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Returns a business logic product from information given by a Product entity /// </summary> /// <param name="CTXProd"></param> /// <returns></returns> public BusinessLogic.Objects.Product ContextInventoryProductToLogicProduct(InventoryProduct CTXProd) { BusinessLogic.Objects.Product BLProd = new BusinessLogic.Objects.Product(); BLProd.productTypeID = CTXProd.ProductTypeId; BLProd.amount = CTXProd.ProductAmount; return(BLProd); }
public void AddProductToInventory() { var inventory = TestInventory(); var product = Product.Create("testprod", "testbrand", "desc", 10); var inventory_product = InventoryProduct.Create("123123", product); inventory.InventoryProducts.Add(inventory_product); Assert.NotNull(inventory.InventoryProducts.First(p => p.ProductInstance == product)); }
public Task <InventoryProduct> GetInventoryProduct(int id, int amount) { var ip = new InventoryProduct { ProductId = id, Amount = amount }; return(new Task <InventoryProduct>(() => ip)); }
public static InventoryProductModel FormDomain(InventoryProduct inventoryProduct) { return(new InventoryProductModel { Id = inventoryProduct.Id, InventoryId = inventoryProduct.InventoryId, ScannedDate = inventoryProduct.ScannedDate, ZoneId = inventoryProduct.ZoneId }); }
public ActionResult confirmStock(int id) { OrderSupply o = db.OrderSupplies.ToList().Where(x => x.orderId == id).FirstOrDefault(); InventoryProduct i = db.Products.ToList().Where(x => x.productName == o.ProductsList).FirstOrDefault(); i.quantityOnHand = i.quantityOnHand + o.itemQty; i.status = "In Stock"; o.status = "Delivered"; db.SaveChanges(); return(RedirectToAction("Index", "OrderSupplies")); }
public ActionResult Edit(int id) { InventoryProduct inventoryProduct = model.GetInventoryItem(id); if (inventoryProduct == null) { return(RedirectToAction("Index", new { error = "Item was not found!" })); } return(View(inventoryProduct)); }
public ActionResult Edit([Bind(Include = "productId,brandName,productName,productDescription,Image,ImageType,categoryId,catalogueId,SupplierId,quantityOnHand,unitPrice,DiscountPrice,totalPrice,onPromotion,status,quantityForQuote")] InventoryProduct inventoryProduct) { if (ModelState.IsValid) { db.Entry(inventoryProduct).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.catalogueId = new SelectList(db.Catalogue_, "catalogueId", "catalogueName", inventoryProduct.catalogueId); ViewBag.categoryId = new SelectList(db.Category_, "categoryId", "categoryName", inventoryProduct.categoryId); ViewBag.SupplierId = new SelectList(db.Suppliers, "supplierid", "supplierName", inventoryProduct.SupplierId); return(View(inventoryProduct)); }
// GET: InventoryProducts/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InventoryProduct inventoryProduct = db.Products.Find(id); if (inventoryProduct == null) { return(HttpNotFound()); } return(View(inventoryProduct)); }
public void AddInventoryProduct(AddItemRequestDto request) { Product product = _productService.GetProductById(request.ProductId); InventoryProduct inventoryProduct = new InventoryProduct { InventoryId = request.InventoryId, ProductId = product.Id, ZoneId = request.ZoneId, ScannedDate = DateTime.Now }; AddInventoryProduct(inventoryProduct); }
// // GET: InventoryProducts/Details/5 //[Authorize(Roles = "Admin")] public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InventoryProduct inventoryProduct = db.Products.Find(id); @ViewBag.Category = db.Category_.FirstOrDefault(a => a.categoryId == inventoryProduct.categoryId).categoryName; if (inventoryProduct == null) { return(HttpNotFound()); } return(View(inventoryProduct)); }
// GET: InventoryProducts/Edit/5 //[Authorize(Roles = "Stock Manager")] public ActionResult EditOnOrder(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InventoryProduct inventoryProduct = db.Products.Find(id); if (inventoryProduct == null) { return(HttpNotFound()); } ViewBag.SupplierId = new SelectList(db.Suppliers, "supplierid", "supplierName", inventoryProduct.SupplierId); return(View(inventoryProduct)); }
public InventoryProduct GetInventoryItemByProductId(int id) { InventoryProduct item = (from e in DB.ProductEntries join p in DB.Products on e.IdProduct equals p.Id where e.Id == id select new InventoryProduct() { Id = e.Id, Name = p.Name, Price = e.UnitPrice, QtdAvailable = p.ProductEntries.Where(r => r.UnitPrice == e.UnitPrice).Sum(r => r.QuantityAvailable) }).FirstOrDefault(); return(item); }
public ActionResult EditOnOrder([Bind(Include = "productId,brandId,brandName,productName,productDescription,Image,categoryId,SupplierId,quantityOnHand,minimumStock,unitPrice,DiscountPrice,totalPrice,prevUnitPrice,quantityToOrder,onPromotion,status,isOrdered,onOrderednum,numRatings")] InventoryProduct inventoryProduct, HttpPostedFileBase upload, string returnUrl) { if (ModelState.IsValid) { if (upload != null && upload.ContentLength > 0) { inventoryProduct.Image = uploader.getFileByte(upload); } db.Entry(inventoryProduct).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("placeOrder", "InventoryProducts", new { inventoryProduct.SupplierId })); } ViewBag.SupplierId = new SelectList(db.Suppliers, "supplierid", "supplierName", inventoryProduct.SupplierId); return(View(inventoryProduct)); }
public ActionResult Create([Bind(Include = "productId,brandId,brandName,productName,productDescription,Image,categoryId,SupplierId,quantityOnHand,minimumStock," + "unitPrice,DiscountPrice,totalPrice,prevUnitPrice,quantityToOrder,onPromotion,status,isOrdered,onOrderednum,numRatings")] InventoryProduct inventoryProduct, HttpPostedFileBase upload) { inventoryProduct.totalPrice = 0; inventoryProduct.brandName = db.brands.FirstOrDefault(a => a.brandId == inventoryProduct.brandId).brandName; inventoryProduct.Image = uploader.getFileByte(upload); if (ModelState.IsValid) { db.Products.Add(inventoryProduct); db.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.categoryId = new SelectList(db.Category_, "categoryId", "categoryName", inventoryProduct.categoryId); ViewBag.SupplierId = new SelectList(db.Suppliers, "supplierid", "supplierName", inventoryProduct.SupplierId); return(View(inventoryProduct)); }
public ActionResult promo(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InventoryProduct inventoryProduct = db.Products.Find(id); if (inventoryProduct == null) { return(HttpNotFound()); } inventoryProduct.onPromotion = true; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult discount(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InventoryProduct inventoryProduct = db.Products.Find(id); if (inventoryProduct == null) { return(HttpNotFound()); } // ViewBag.categoryId = new SelectList(db.Category_, "categoryId", "categoryName", inventoryProduct.categoryId); ViewBag.SupplierId = new SelectList(db.Suppliers, "supplierid", "supplierName"); return(View(inventoryProduct)); }
public ActionResult Create( [Bind(Include = "Id,IdProduct,Name,Qtd,Price,PriceAcquisition,DatePurchase")] InventoryProduct product) { if (ModelState.IsValid) { ResultOperation result = model.Save(product); if (result.Success) { return(RedirectToAction("Index", new { success = "Item was successfully created" })); } ModelState.AddModelError("Name", result.Message); } return(View(product)); }
public decimal CalculateLbsPerUnit(InventoryProduct product) { if (product.UnitType == UnitType.Lbs.ToString()) { return(product.SizeOfUnit); } if (product.UnitType == UnitType.Oz.ToString()) { return(Math.Round(Convert.ToDecimal(Convert.ToDecimal(product.SizeOfUnit) / 16), 2)); } if (product.UnitType == UnitType.Tons.ToString()) { return(product.SizeOfUnit * 2000); } return(0); }
public ActionResult placeOrder(InventoryProductList model) { var checkinSelected = model.inventory.Where(a => a.isOrdered == true).ToList(); if (checkinSelected == null || checkinSelected.Count < 1) { return(RedirectToAction("Alert")); } var selectedProd = model.inventory.Where(x => x.isOrdered == true).ToList(); string productsOrdered = ""; string supplierName = ""; string suplierEmail = ""; string managerEmail = User.Identity.GetUserName(); foreach (InventoryProduct v in selectedProd) { OrderSupply o = new OrderSupply(); o.supplierEmail = db.Suppliers.ToList().Where(x => x.supplierid == v.SupplierId).FirstOrDefault().supplierEmail; o.supplier = db.Suppliers.ToList().Where(x => x.supplierid == v.SupplierId).FirstOrDefault().supplierName; o.suplyNum = db.Suppliers.ToList().Where(x => x.supplierid == v.SupplierId).FirstOrDefault().supplierNumber; o.itemQty = db.Products.ToList().Where(x => x.productId == v.productId).FirstOrDefault().quantityToOrder; o.totalOrder = (db.Products.ToList().Where(x => x.productId == v.productId).FirstOrDefault().quantityToOrder) * (db.Products.ToList().Where(x => x.productId == v.productId).FirstOrDefault().prevUnitPrice); o.dateOrdered = DateTime.Now.ToString(); o.ProductsList = db.Products.ToList().Where(x => x.productId == v.productId).FirstOrDefault().productName; o.status = "Pending"; o.isOrdered = true; o.orderedBy = User.Identity.GetUserName(); suplierEmail = db.Suppliers.ToList().Where(x => x.supplierid == v.SupplierId).FirstOrDefault().supplierEmail; supplierName = db.Suppliers.ToList().Where(x => x.supplierid == v.SupplierId).FirstOrDefault().supplierName; productsOrdered += $" { o.ProductsList} ({o.itemQty}), "; InventoryProduct pp = db.Products.ToList().Where(x => x.productId == v.productId).FirstOrDefault(); pp.status = "Ordered"; db.OrderSupplies.Add(o); db.SaveChanges(); } if (suplierEmail != null) { string msg = $"Hi {supplierName}. We would like to order the following products { productsOrdered } Contact us at [email protected] for enquiries."; emailhelper.sendMail(suplierEmail, "Placing new order", msg); string newMsg = $"Hi you have placed an order to { supplierName} for the following products { productsOrdered } Contact us at [email protected] for enquiries."; emailhelper.sendMail(managerEmail, "Placed new order", newMsg); } return(View("addProdSuc")); }
public ActionResult Complete() { var cart = ShoppingCart.GetCart(this.HttpContext); InventoryProduct st = new InventoryProduct(); foreach (var prod in cart.GetCartItems()) { st = db.Products.ToList().Find(a => a.productId == prod.productID); var inv = db.Products.ToList().Find(x => x.productId == st.productId); inv.quantityOnHand = inv.quantityOnHand - prod.Count; //pa.save(prod.product.productName, prod.Count); } db.SaveChanges(); cart.EmptyCart(); return(RedirectToAction("MyOrders")); }
public ActionResult Quote([Bind(Include = "productId,brandName,productName,productDescription,Image,ImageType,categoryId,catalogueId,quantityOnHand,quantityForQuote,unitPrice,DiscountPrice,totalPrice,supplierid,onPromotion")] InventoryProduct inventoryProduct, HttpPostedFileBase file) { if (ModelState.IsValid) { if (file != null && file.ContentLength > 0) { inventoryProduct.ImageType = Path.GetExtension(file.FileName); inventoryProduct.Image = ConvertToBytes(file); } db.Entry(inventoryProduct).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("LowStock")); } ViewBag.catalogueId = new SelectList(db.Catalogue_, "catalogueId", "catalogueName", inventoryProduct.catalogueId); ViewBag.categoryId = new SelectList(db.Category_, "categoryId", "categoryName", inventoryProduct.categoryId); ViewBag.supplierid = new SelectList(db.Suppliers, "supplierid", "supplierName", inventoryProduct.SupplierId); return(View(inventoryProduct)); }
public InventoryProduct GetInventoryItemByProductId(int id) { InventoryProduct item = (from e in DB.ProductEntries join p in DB.Products on e.IdProduct equals p.Id where p.Id == id orderby e.PurchaseDate descending select new InventoryProduct() { IdProduct = p.Id, Name = p.Name, Qtd = e.QuantityBought, Price = e.UnitPrice, PriceAcquisition = e.UnitPriceAcquisition, DatePurchase = DateTime.Now }).FirstOrDefault(); return(item); }