public OrdersModel(IWarehouse context, IOrderService order, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager) { _context = context; _order = order; _userManager = userManager; _signInManager = signInManager; }
internal HttpResponseMessage PutWarehouses(IEnumerable <WarehouseDisplay> warehouses) { var response = Request.CreateResponse(HttpStatusCode.OK); if (warehouses != null) { try { foreach (var warehouse in warehouses) { IWarehouse merchWarehouse = _warehouseService.GetByKey(warehouse.Key); merchWarehouse = warehouse.ToWarehouse(merchWarehouse); _warehouseService.Save(merchWarehouse); } } catch (Exception ex) { response = Request.CreateResponse(HttpStatusCode.NotFound, String.Format("{0}", ex.Message)); } } else { response = Request.CreateResponse(HttpStatusCode.NotFound, String.Format("Parameter warehouses in null")); } return(response); }
public AdminController(IWarehouse context, IOrderService orders, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager) { _context = context; _orders = orders; _userManager = userManager; _signInManager = signInManager; }
public void Initialize(IWarehouse warehouse, IStorageScope scope) { Warehouse = warehouse; Scope = scope; // there's no other work for a memshelf }
public void Fill(IWarehouse warehouse) { if (warehouse.HasAmount(this.OrderedProduct, this.OrderedAmount) == true) { warehouse.Remove(this); } }
public static IWarehouse MockSavedWithKey(this IWarehouse entity, Guid key) { entity.Key = key; ((Entity)entity).AddingEntity(); entity.ResetDirtyProperties(); return(entity); }
private static void AdjustStockItemQuantity(LineItem lineItem) { if (lineItem.CatalogEntryId == "0" && String.IsNullOrEmpty(lineItem.CatalogEntryId) && lineItem.CatalogEntryId.StartsWith("@")) { return; } var entryDto = CatalogContext.Current.GetCatalogEntryDto(lineItem.CatalogEntryId, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull)); var catalogEntry = GetCatalogEntry(entryDto); if (catalogEntry != null && CheckNeedEntryTracking(catalogEntry)) { decimal changeInInventory = -lineItem.Quantity; IWarehouse warehouse = ServiceLocator.Current.GetInstance <IWarehouseRepository>().Get(lineItem.WarehouseCode); if (warehouse != null) { IWarehouseInventory inventory = ServiceLocator.Current.GetInstance <IWarehouseInventoryService>() .Get(new CatalogKey(catalogEntry), warehouse); if (inventory != null) { AdjustStockInventoryQuantity(lineItem, inventory, changeInInventory); } } } }
public Simulations(ILogger logger, IWarehouse warehouse, ICustomerBase customerBase, IShop shop) { this.logger = logger; Warehouse = warehouse; CustomerBase = customerBase; Shop = shop; }
/// <summary> /// Checks the warehouse assigned to an order line item to determine if it is a valid shipment fulfillment location /// (i.e. will ship items to a customer address) /// </summary> /// <param name="warehouse">The intended source warehouse.</param> /// <param name="lineItem">The order line item.</param> /// <param name="checkInventory">Set to false to override the check against current stock.</param> /// <returns> /// true if the warehouse can ship the item and a pickup method is not already chosen; otherwise false /// (i.e. the warehouse cannot ship the item, or the line item has an in-store pickup method selected). /// </returns> private bool IsValidFulfillment(IWarehouse warehouse, LineItem lineItem, CheckInventoryMode checkInventory) { if (warehouse == null || lineItem == null) { throw new ArgumentNullException(); } var shippingMethod = ShippingManager.GetShippingMethod(lineItem.ShippingMethodId).ShippingMethod.FirstOrDefault(); if (shippingMethod != null && ShippingManager.IsHandoffShippingMethod(shippingMethod.Name)) { return(false); } var lineApplicationId = lineItem.Parent.Parent.ApplicationId; if ((warehouse.ApplicationId != lineApplicationId) || !warehouse.IsActive || !warehouse.IsFulfillmentCenter) { return(false); } if (checkInventory == CheckInventoryMode.Ignore) { return(true); } var catalogKey = new Mediachase.Commerce.Catalog.CatalogKey(lineItem.Parent.Parent.ApplicationId, lineItem.CatalogEntryId); var inventory = InventoryService.Service.Get(catalogKey, warehouse); return(IsEnoughQuantity(inventory, lineItem)); }
private static void SetPickUpButton(RepeaterItemEventArgs e, IWarehouse warehouse, Inventory warehouseInventory) { var pickupButton = e.Item.FindControl("PickUpButton") as HyperLink; if (pickupButton == null) { return; } if (warehouse.IsFulfillmentCenter || warehouse.IsPickupLocation || warehouse.IsDeliveryLocation) { if (warehouse.IsFulfillmentCenter || warehouse.IsPickupLocation) { pickupButton.Text = "Pick"; } else if (warehouse.IsDeliveryLocation) { pickupButton.Text = "Delivery-only"; } pickupButton.Attributes.Add("onclick", String.Format("SelectWarehouse('{0}','{1}','{2}');", warehouseInventory.InStockQuantity, warehouseInventory.WarehouseCode, warehouse.Name)); } else { pickupButton.Text = "Not set"; pickupButton.CssClass += " disabled"; } }
public void Init() { _warehouse = PreTestDataWorker.WarehouseService.GetDefaultWarehouse(); PreTestDataWorker.DeleteAllProducts(); _productService = PreTestDataWorker.ProductService; _productVariantService = PreTestDataWorker.ProductVariantService; _product = PreTestDataWorker.MakeExistingProduct(); _product.ProductOptions.Add(new ProductOption("Color")); _product.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Black", "Blk")); _product.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Blue", "Blu")); _product.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Red", "Red")); _product.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Green", "Gre")); _product.ProductOptions.Add(new ProductOption("Size")); _product.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Small", "Sm")); _product.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Medium", "M")); _product.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Large", "Lg")); _product.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("X-Large", "XL")); _product.Height = 20; _product.Weight = 20; _product.Length = 20; _product.Width = 20; _product.Shippable = true; _productService.Save(_product); }
public Buyer(ILogger logger, ICustomerBase customerBase, IWarehouse warehouse, IShop shop) { this.logger = logger; CustomerBase = customerBase; Warehouse = warehouse; Shop = shop; }
public int Save(IWarehouse warehouse) { Console.WriteLine("[" + this.GetType().ToString() + "]" + " Saving warehouse"); int newId = ++id; storage.Add(newId, warehouse); return(newId); }
public void Fill(IWarehouse warehouse) { if (warehouse.HasInventory(_itemName, _itemQuantity)) { IsFilled = true; warehouse.Remove(_itemName, _itemQuantity); } }
public void Fill(IWarehouse warehouse) { if (!warehouse.HasInventory(ProductName, Quantity)) return; warehouse.Remove(ProductName, Quantity); IsFilled = true; }
public void Init() { var warehouseService = PreTestDataWorker.WarehouseService; _warehouse = warehouseService.GetDefaultWarehouse(); _warehouseCatalog = _warehouse.DefaultCatalog(); }
public void Fill(IWarehouse warehouse) { if (warehouse.HasInventory(ProductName, Quantity)) { warehouse.Remove(ProductName, Quantity); IsFilled = true; } }
public DatabaseController(IWarehouse currentwarehouse) { if (currentwarehouse == null) { throw new Exception("Wrong database service name"); } CurrentWarehouse = currentwarehouse; }
private bool IsValidSingleShippment() { // Check valid line item for Single Shipment if (Cart.OrderForms.Count > 0) { List <string> warehouseCodes = new List <string>(); var lineItems = Cart.OrderForms[0].LineItems; foreach (LineItem lineItem in lineItems) { if (!warehouseCodes.Contains(lineItem.WarehouseCode)) { warehouseCodes.Add(lineItem.WarehouseCode); } } // Cart only has one warehouse instore pickup if (warehouseCodes.Count == 1) { // Shipping method is "In store pickup", add address to Cart & Shipment IWarehouse warehouse = WarehouseHelper.GetWarehouse(warehouseCodes.FirstOrDefault()); if (!warehouse.IsFulfillmentCenter && warehouse.IsPickupLocation) { Shipment.WarehouseCode = warehouse.Code; if (CartHelper.FindAddressByName(warehouse.Name) == null) { var address = warehouse.ContactInformation.ToOrderAddress(); address.Name = warehouse.Name; Cart.OrderAddresses.Add(address); } Shipment.ShippingAddressId = warehouse.Name; Shipment.ShippingMethodName = ShippingManager.PickupShippingMethodName; var instorepickupShippingMethod = ShippingManager.GetShippingMethods("en").ShippingMethod.ToArray().Where(m => m.Name.Equals(ShippingManager.PickupShippingMethodName)).FirstOrDefault(); if (instorepickupShippingMethod != null) { Shipment.ShippingMethodId = instorepickupShippingMethod.ShippingMethodId; } Cart.AcceptChanges(); } } else { foreach (string warehouseCode in warehouseCodes) { IWarehouse warehouse = WarehouseHelper.GetWarehouse(warehouseCode); if (warehouse != null && warehouse.IsPickupLocation) { return(false); } } } } return(true); }
private void Run(IWarehouse warehouse) { var startPosition = GetRobotStartingPosition(); var commands = GetRobotCommands(); var robot = new Robot(warehouse, int.Parse(startPosition[0]), int.Parse(startPosition[1]), char.Parse(startPosition[2].ToUpper())); robot.ProcessCommands(commands); Console.WriteLine("Robots new position: " + robot.Position); }
public GameController(IWriter writer) { this.army = new Army(); this.wearHouse = new Warehouse(); this.missionController = new MissionController(army, wearHouse); this.soldierFactory = new SoldierFactory(); this.missionFactory = new MissionFactory(); this.writer = writer; }
public ShopController(IWarehouse context, ICartService cart, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager) { _context = context; _cart = cart; _userManager = userManager; _signInManager = signInManager; }
public void SupplyPhonesToWarehouse(IPhone phone, IWarehouse warehouse) { warehouse.StorePhone(phone, 10); if (null != phonesSuppliedListener) { phonesSuppliedListener.OnPhonesSupplied("10 demo phones: " + phone.PhoneName + " was stored in warehouse at: " + warehouse.Location); } }
public int OpenWarehouse(string location, int capacity) { Console.WriteLine("[" + this.GetType().ToString() + "]" + " Creating warehouse"); IWarehouse newWarehouse = productionFactory.CreateWarehouse(location, capacity); Console.WriteLine("[" + this.GetType().ToString() + "]" + " Saving warehouse to repository"); int warehouseId = warehouses.Save(newWarehouse); return(warehouseId); }
public override void FixtureSetup() { base.FixtureSetup(); var warehouseService = this.PreTestDataWorker.WarehouseService; this._warehouse = warehouseService.GetDefaultWarehouse(); this._provider = (ProductIndexer)ExamineManager.Instance.IndexProviderCollection["MerchelloProductIndexer"]; this._provider.RebuildIndex(); }
public void Fill(IWarehouse warehouse) { if (!warehouse.HasInventory(product, amount)) { return; } warehouse.RemoveInventory(product, amount); IsFilled = true; }
public void Fill(IWarehouse warehouse) { bool IsAvalible = false; IsAvalible = warehouse.HasInventory(this.Item, this.Amount); if (IsAvalible) { warehouse.Remove(this.Item, this.Amount); this.IsFilled = true; } }
public void Fill(IWarehouse warehouse) { if (!warehouse.HasInventory(product, amount)) { Mailer.Send(new Message(text: string.Format("Not enought amount of {0}", product), to: "*****@*****.**")); return; } warehouse.RemoveInventory(product, amount); IsFilled = true; }
/// <summary> /// Returns default warehouse for the store /// /// GET /umbraco/Merchello/WarehouseApi/GetDefaultWarehouse /// </summary> /// <returns> /// The <see cref="WarehouseDisplay"/>. /// </returns> public WarehouseDisplay GetDefaultWarehouse() { IWarehouse warehouse = _warehouseService.GetDefaultWarehouse(); if (warehouse == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(warehouse.ToWarehouseDisplay()); }
public static DataSet NewRetrieve(IWarehouse warehouse, Int32 SearchOption) { SqlParameter[] _parameters = { new SqlParameter("@Warehouse", warehouse.warehouse) , new SqlParameter("@Description", warehouse.WhseLocation) , new SqlParameter("@SearchOption", SearchOption) }; return(SqlHelper.ExecuteDataset(ConnectionString, "sp_NewWarehouses_Search", _parameters)); }
public void FillingOrderRemovesWarehouseItemsWhenSufficientStockIsAvailable() { Order order = new Order("milk", 20); IWarehouse warehouse = MockRepository.GenerateMock <IWarehouse>(); warehouse.Stub(x => x.HasInventory("milk", 20)).Return(true); order.Fill(warehouse); warehouse.AssertWasCalled(x => x.Remove("milk", 20)); }
public void FillingOrderChecksTheWarehouseInventory() { Order order = new Order("milk", 20); IWarehouse warehouse = MockRepository.GenerateMock <IWarehouse>(); warehouse.Expect(x => x.HasInventory("milk", 20)).Return(false); order.Fill(warehouse); warehouse.VerifyAllExpectations(); }
public Robot(IWarehouse warehouse, int startX, int startY, char startOrientation) { const string compassPoints = "NESW"; if (!compassPoints.Contains(startOrientation)) { throw new Exception("Invalid orientation"); } if (!warehouse.IsValidCoordinate(startX, startY)) { throw new Exception("Invalid position"); } _warehouse = warehouse; _x = startX; _y = startY; _orientation = startOrientation; }
public void Init() { var warehouseService = PreTestDataWorker.WarehouseService; _warehouse = warehouseService.GetDefaultWarehouse(); StoreSettingService = PreTestDataWorker.StoreSettingService; //IStoreSetting currencyCode = new StoreSetting() //{ // Key = _currencyCodeKey, // Name = "currencyCode", // Value = "USD" //}; //StoreSettingService.Save(currencyCode); //IStoreSetting nextInvoiceNumber = new StoreSetting() //{ // Key = _nextInvoiceNumberKey, // Name = "currencyCode", // Value = "10" //}; //StoreSettingService.Save(nextInvoiceNumber); //IStoreSetting nextOrderNumber = new StoreSetting() //{ // Key = _nextOrderNumberkey, // Name = "currencyCode", // Value = "10" //}; //StoreSettingService.Save(nextOrderNumber); //IStoreSetting timeFormat = new StoreSetting() //{ // Key = _timeFormatKey, // Name = "currencyCode", // Value = "am-pm" //}; //StoreSettingService.Save(timeFormat); //IStoreSetting dateFormat = new StoreSetting() //{ // Key = _dateFormatKey, // Name = "currencyCode", // Value = "dd-mm-yyyy" //}; //StoreSettingService.Save(dateFormat); //IStoreSetting globalShippable = new StoreSetting() //{ // Key = _globalShippableKey, // Name = "currencyCode", // Value = "false" //}; //StoreSettingService.Save(globalShippable); //IStoreSetting globalShippingIsTaxable = new StoreSetting() //{ // Key = _globalShippingIsTaxableKey, // Name = "currencyCode", // Value = "false" //}; //StoreSettingService.Save(globalShippingIsTaxable); //IStoreSetting globalTaxable = new StoreSetting() //{ // Key = _globalTaxableKey, // Name = "currencyCode", // Value = "false" //}; //StoreSettingService.Save(globalTaxable); //IStoreSetting globalTrackInventory = new StoreSetting() //{ // Key = _globalTrackInventoryKey, // Name = "currencyCode", // Value = "false" //}; //StoreSettingService.Save(globalTrackInventory); }
public void Init() { var warehouseService = PreTestDataWorker.WarehouseService; _warehouse = warehouseService.GetDefaultWarehouse(); var productService = PreTestDataWorker.ProductService; var product = MockProductDataMaker.MockProductCollectionForInserting(1).First(); product.ProductOptions.Add(new ProductOption("Color")); product.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Blue", "Blue")); product.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Red", "Red")); product.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Green", "Green")); product.ProductOptions.Add(new ProductOption("Size")); product.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Small", "Sm")); product.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Medium", "Med")); product.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Large", "Lg")); product.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("X-Large", "XL")); product.Height = 11M; product.Width = 11M; product.Length = 11M; product.CostOfGoods = 15M; product.OnSale = true; product.SalePrice = 18M; product.Manufacturer = "Nike"; product.ManufacturerModelNumber = "N01-012021-A"; product.TrackInventory = true; product.AddToCatalogInventory(_warehouse.WarehouseCatalogs.First()); productService.Save(product); foreach (var variant in product.ProductVariants) { foreach (var inv in variant.CatalogInventories) { inv.Count = 1; } } productService.Save(product); _productKey = product.Key; _productVariantKey = product.ProductVariants.First().Key; _examineId = ((ProductVariant)product.ProductVariants.First()).ExamineId; var provider = (ProductIndexer)ExamineManager.Instance.IndexProviderCollection["MerchelloProductIndexer"]; provider.AddProductToIndex(product); }
public override void FixtureSetup() { base.FixtureSetup(); var warehouseService = this.PreTestDataWorker.WarehouseService; this._warehouse = warehouseService.GetDefaultWarehouse(); this._provider = (ProductIndexer)ExamineManager.Instance.IndexProviderCollection["MerchelloProductIndexer"]; //this._provider.RebuildIndex(); }
/// <summary> /// Checks the warehouse assigned to an order line item to determine if it is a valid shipment fulfillment location /// (i.e. will ship items to a customer address) /// </summary> /// <param name="warehouse">The intended source warehouse.</param> /// <param name="lineItem">The order line item.</param> /// <param name="checkInventory">Set to false to override the check against current stock.</param> /// <returns> /// true if the warehouse can ship the item and a pickup method is not already chosen; otherwise false /// (i.e. the warehouse cannot ship the item, or the line item has an in-store pickup method selected). /// </returns> private bool IsValidFulfillment(IWarehouse warehouse, LineItem lineItem, CheckInventoryMode checkInventory) { if (warehouse == null || lineItem == null) { throw new ArgumentNullException(); } var shippingMethod = ShippingManager.GetShippingMethod(lineItem.ShippingMethodId).ShippingMethod.FirstOrDefault(); if (shippingMethod != null && ShippingManager.IsHandoffShippingMethod(shippingMethod.Name)) { return false; } var lineApplicationId = lineItem.Parent.Parent.ApplicationId; if ((warehouse.ApplicationId != lineApplicationId) || !warehouse.IsActive || !warehouse.IsFulfillmentCenter) { return false; } if (checkInventory == CheckInventoryMode.Ignore) { return true; } var catalogKey = new Mediachase.Commerce.Catalog.CatalogKey(lineItem.Parent.Parent.ApplicationId, lineItem.CatalogEntryId); var inventory = InventoryService.Service.Get(catalogKey, warehouse); return IsEnoughQuantity(inventory, lineItem); }
public override void FixtureSetup() { base.FixtureSetup(); var warehouseService = PreTestDataWorker.WarehouseService; _warehouse = warehouseService.GetDefaultWarehouse(); _warehouseCatalog = _warehouse.DefaultCatalog(); var key = Constants.ProviderKeys.Shipping.FixedRateShippingProviderKey; _fixedRateProvider = (FixedRateShippingGatewayProvider)MerchelloContext.Gateways.Shipping.ResolveByKey(key); var shipCountryService = PreTestDataWorker.ShipCountryService; _shipCountry = shipCountryService.GetShipCountryByCountryCode(_warehouseCatalog.Key, "US"); }
/// <summary> /// Saves a single <see cref="IWarehouse"/> object /// </summary> /// <param name="warehouse">The <see cref="IWarehouse"/> to save</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events.</param> public void Save(IWarehouse warehouse, bool raiseEvents = true) { if (raiseEvents) Saving.RaiseEvent(new SaveEventArgs<IWarehouse>(warehouse), this); using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateWarehouseRepository(uow)) { repository.AddOrUpdate(warehouse); uow.Commit(); } if (raiseEvents) Saved.RaiseEvent(new SaveEventArgs<IWarehouse>(warehouse), this); } }
internal static IWarehouse ToWarehouse(this WarehouseDisplay warehouseDisplay, IWarehouse destination) { if (warehouseDisplay.Key != Guid.Empty) { destination.Key = warehouseDisplay.Key; } destination.Name = warehouseDisplay.Name; destination.Address1 = warehouseDisplay.Address1; destination.Address2 = warehouseDisplay.Address2; destination.Locality = warehouseDisplay.Locality; destination.Region = warehouseDisplay.Region; destination.PostalCode = warehouseDisplay.PostalCode; destination.CountryCode = warehouseDisplay.CountryCode; destination.Phone = warehouseDisplay.Phone; destination.Email = warehouseDisplay.Email; destination.IsDefault = warehouseDisplay.IsDefault; foreach (var warehouseCatalogDisplay in warehouseDisplay.WarehouseCatalogs) { IWarehouseCatalog destinationWarehouseCatalog; var matchingItems = destination.WarehouseCatalogs.Where(x => x.Key == warehouseCatalogDisplay.Key); if (matchingItems.Any()) { var existingWarehouseCatalog = matchingItems.First(); if (existingWarehouseCatalog != null) { destinationWarehouseCatalog = existingWarehouseCatalog; destinationWarehouseCatalog = warehouseCatalogDisplay.ToWarehouseCatalog(destinationWarehouseCatalog); } } } return destination; }
/// <summary> /// Deletes a single <see cref="IWarehouse"/> object /// </summary> /// <param name="warehouse">The <see cref="IWarehouse"/> to delete</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> internal void Delete(IWarehouse warehouse, bool raiseEvents = true) { if (raiseEvents) Deleting.RaiseEvent(new DeleteEventArgs<IWarehouse>( warehouse), this); using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateWarehouseRepository(uow)) { repository.Delete( warehouse); uow.Commit(); } } if (raiseEvents) Deleted.RaiseEvent(new DeleteEventArgs<IWarehouse>( warehouse), this); }