protected virtual string ToInventoryStatus(InventoryInformation inventoryInformation) { if (inventoryInformation.Quantity > 0) { return(Engine.CatalogConstants.InventoryStatus.InStock); } if (inventoryInformation.HasComponent <PreorderableComponent>()) { var component = inventoryInformation.GetComponent <PreorderableComponent>(); if (component.Preorderable && component.PreorderLimit > 0 && component.PreorderedQuantity < component.PreorderLimit) { return(Engine.CatalogConstants.InventoryStatus.OnPreOrder); } } if (inventoryInformation.HasComponent <BackorderableComponent>()) { var component = inventoryInformation.GetComponent <BackorderableComponent>(); if (component.Backorderable && component.BackorderLimit > 0 && component.BackorderedQuantity < component.BackorderLimit) { return(Engine.CatalogConstants.InventoryStatus.OnBackOrder); } } return(Engine.CatalogConstants.InventoryStatus.OutOfStock); }
private void OnBarcodeEnteredCommandExecuted(string barcode) { if (InventoryInformation == null || InventoryInformation.ItemBarcode != barcode) { InventoryInformation = new InventoryInformation() { ItemName = "Tornillos", ItemDescription = @"D:\TGW\bin\PDEnvironment\SCOTe.Agent\v2\Projects\BuildSolution.proj(221,5): warning : CompleteTransportRequest.cs(15,18): warning CS1591: Missing XML comment for publicly visible type or member 'CompleteTransportRequest' [D:\_B\6837055\B\8\Products\SharedCode\ManualTransports\ManualTransports.Facade.Messages\ManualTransports.Facade.Messages.csproj] D:\TGW\bin\PDEnvironment\SCOTe.Agent\v2\Projects\BuildSolution.proj(221, 5): warning : CompleteTransportResponse.cs(16, 18): warning CS1591: Missing XML comment for publicly visible type or member 'CompleteTransportResponse'[D:\_B\6837055\B\8\Products\SharedCode\ManualTransports\ManualTransports.Facade.Messages\ManualTransports.Facade.Messages.csproj]", ItemLocation = "Pasillo 1 / Armario 2 / Estanteria 4 / Posición 3", QuantityAvailable = 10, ItemBarcode = barcode }; ItemImagePath = @"C:\Users\rbo\Pictures\tornillos.jpg"; QuantitySelected = 1; } else { if (IncreaseQuantityCommand.CanExecute()) { IncreaseQuantityCommand.Execute(); } } RaisePropertiesChanged(); }
protected async Task <Tuple <InventoryInformation, bool> > GetInventoryInformation(CommercePipelineExecutionContext context, CommerceEntity commerceEntity, string inventorySetId, string variantId) { bool associationExists = false; InventoryInformation inventoryInformation = await _commerceCommander .Command <GetInventoryInformationCommand>().Process(context.CommerceContext, inventorySetId, commerceEntity.Id, variantId).ConfigureAwait(false); FindEntitiesInListArgument entitiesInListArgument1 = new FindEntitiesInListArgument(typeof(SellableItem), "InventorySetToInventoryInformation-" + inventorySetId.SimplifyEntityName(), 0, int.MaxValue); entitiesInListArgument1.LoadEntities = false; FindEntitiesInListArgument entitiesInListArgument2 = await _commerceCommander .Pipeline <FindEntitiesInListPipeline>().Run(entitiesInListArgument1, context) .ConfigureAwait(false); if (inventoryInformation != null && entitiesInListArgument2 != null) { IList <ListEntityReference> entityReferences = entitiesInListArgument2.EntityReferences; bool?nullable = entityReferences != null ? entityReferences.Any(x => x.EntityUniqueId.Equals(inventoryInformation.UniqueId)) : new bool?(); associationExists = nullable.HasValue && nullable.Value; } return(new Tuple <InventoryInformation, bool>(inventoryInformation, associationExists)); }
public ActionResult SubmitInventory(InventoryInformation model) { // Do stuff // When done please navigate back to this view return(RedirectToAction(nameof(Index))); }
private void CopyCore(InventoryInformation itemNewData, InventoryInformation item) { // These fields are not included // item.ProductId // item.Id // item.FriendlyId // item.Name // item.SitecoreId item.Quantity = itemNewData.Quantity; // item.Description = itemNewData.Description; // Not being imported at the moment so expect it will be managed manually. }
public ActionResult InventoryDetail(string barcodeId) { var viewModel = new InventoryInformation() { ItemName = "Tornillos", ItemDescription = @"D:\TGW\bin\PDEnvironment\SCOTe.Agent\v2\Projects\BuildSolution.proj(221,5): warning : CompleteTransportRequest.cs(15,18): warning CS1591: Missing XML comment for publicly visible type or member 'CompleteTransportRequest' [D:\_B\6837055\B\8\Products\SharedCode\ManualTransports\ManualTransports.Facade.Messages\ManualTransports.Facade.Messages.csproj] D:\TGW\bin\PDEnvironment\SCOTe.Agent\v2\Projects\BuildSolution.proj(221, 5): warning : CompleteTransportResponse.cs(16, 18): warning CS1591: Missing XML comment for publicly visible type or member 'CompleteTransportResponse'[D:\_B\6837055\B\8\Products\SharedCode\ManualTransports\ManualTransports.Facade.Messages\ManualTransports.Facade.Messages.csproj]", ItemLocation = "Pasillo 1 / Armario 2 / Estanteria 4 / Posición 3", QuantityAvailable = 10, ItemBarcode = barcodeId }; return(View(viewModel)); }
public ActionResult Inventory() { var viewModel = new InventoryInformation() { ItemName = "Scan Item", ItemDescription = string.Empty, ItemLocation = "Pasillo 1 / Armario 2 / Estanteria 4 / Posición 3", QuantityAvailable = 0, ItemBarcode = string.Empty }; return(View(viewModel)); }
private async Task AssociateInventoryInformationToSellableItem(CommerceContext commerceContext, string inventorySetId, InventoryInformation inventoryInformation) { // Associate inventory information to sellable item // Establish relationship between inventory set and inventory information await _inventoryCommander.Pipeline<ICreateRelationshipPipeline>().RunAsync( new RelationshipArgument( inventorySetId, inventoryInformation.Id, InventoryConstants.InventorySetToInventoryInformation) {TargetType = typeof(InventoryInformation)}, commerceContext.PipelineContext) .ConfigureAwait(false); }
private void ResetView() { InventoryInformation = new InventoryInformation() { ItemName = "Scan Item", ItemDescription = string.Empty, ItemLocation = "Pasillo 1 / Armario 2 / Estanteria 4 / Posición 3", QuantityAvailable = 0, ItemBarcode = string.Empty }; ItemImagePath = @"pack://application:,,,/Nerob.Client.Shared;component/Images/questionMark.png"; QuantitySelected = 0; }
public Task <IEnumerable <InventoryInformation> > Process(CommerceContext commerceContext, IEnumerable <string[]> importRawLines) { using (CommandActivity.Start(commerceContext, this)) { var importPolicy = commerceContext.GetPolicy <ImportInventoryPolicy>(); var importItems = new List <InventoryInformation>(); foreach (var rawFields in importRawLines) { var item = new InventoryInformation(); TransformCore(commerceContext, rawFields, item); importItems.Add(item); } return(Task.FromResult(importItems as IEnumerable <InventoryInformation>)); } }
private async Task UpdateSellableItem(CommerceContext commerceContext, string sellableItemId, string variationId, InventoryInformation inventoryInformation, string inventorySetId) { // Update all sellable item versions. var versions = await _inventoryCommander.Pipeline<IFindEntityVersionsPipeline>() .RunAsync(new FindEntityArgument(typeof(SellableItem), sellableItemId), commerceContext.PipelineContext) .ConfigureAwait(false); foreach (var sellableItemVersion in versions.Cast<SellableItem>()) { var sellableItemVersionVariation = sellableItemVersion.GetVariation(variationId); if (sellableItemVersionVariation == null) { // Check if this variation exists in any other variation. if (versions.Cast<SellableItem>().Any(version => version.GetVariation(variationId) != null)) { continue; } } var inventoryComponent = sellableItemVersionVariation != null ? sellableItemVersionVariation.GetComponent<InventoryComponent>() : sellableItemVersion.GetComponent<InventoryComponent>(); inventoryComponent.InventoryAssociations.Add(new InventoryAssociation { InventoryInformation = new EntityReference(inventoryInformation.Id), InventorySet = new EntityReference(inventorySetId) }); await _inventoryCommander.Pipeline<IPersistEntityPipeline>() .RunAsync(new PersistEntityArgument(sellableItemVersion), commerceContext.PipelineContext) .ConfigureAwait(false); } }
private static InventoryInformation CreateInventoryInformation(InventoryModel inventory, string inventoryId, string friendlyId, string inventorySetId) { // Create an InventoryInformationObject var inventoryInformation = new InventoryInformation(); inventoryInformation.Id = inventoryId; inventoryInformation.FriendlyId = friendlyId; inventoryInformation.SellableItem = new EntityReference(inventory.SellableItemId); inventoryInformation.InventorySet = new EntityReference(inventorySetId); inventoryInformation.Quantity = inventory.Quantity; inventoryInformation.InvoiceUnitPrice = inventory.InvoiceUnitPrice; if (inventory.Backorderable) { var backorderableComponent = inventoryInformation.GetComponent<BackorderableComponent>(); backorderableComponent.Backorderable = inventory.Backorderable; backorderableComponent.BackorderAvailabilityDate = inventory.BackorderAvailabilityDate; backorderableComponent.BackorderedQuantity = inventory.BackorderedQuantity; backorderableComponent.BackorderLimit = inventory.BackorderLimit; } if (inventory.Preorderable) { var preorderableComponent = inventoryInformation.GetComponent<PreorderableComponent>(); preorderableComponent.Preorderable = inventory.Preorderable; preorderableComponent.PreorderAvailabilityDate = inventory.PreorderAvailabilityDate; preorderableComponent.PreorderedQuantity = inventory.PreorderedQuantity; preorderableComponent.PreorderLimit = inventory.PreorderLimit; } // Add to list of Inventory Informations inventoryInformation.GetComponent<TransientListMembershipsComponent>().Memberships.Add( CommerceEntity.ListName<InventoryInformation>()); return inventoryInformation; }
/// <summary> /// Adds the view properties. /// </summary> /// <param name="entityView">The entity view.</param> /// <param name="sellableItem">The sellable item.</param> /// <param name="variationId">The variation identifier.</param> /// <param name="inventoryInformation">The <see cref="InventoryInformation"/> of the sellable item for the inventory set.</param> /// <param name="context">The context.</param> /// <returns>A <see cref="Task"/></returns> private async Task AddViewProperties( EntityView entityView, SellableItem sellableItem, string variationId, InventoryInformation inventoryInformation, CommercePipelineExecutionContext context) { entityView.Properties.Add(new ViewProperty { Name = "SellableItem", RawValue = string.IsNullOrEmpty(variationId) ? sellableItem?.Id : $"{sellableItem.Id}|{variationId}", IsReadOnly = true }); entityView.Properties.Add(new ViewProperty { Name = "Quantity", RawValue = inventoryInformation?.Quantity ?? 0 }); entityView.Properties.Add(new ViewProperty { Name = "InvoiceUnitPrice", RawValue = inventoryInformation?.InvoiceUnitPrice?.Amount ?? 0, OriginalType = typeof(decimal).FullName, IsRequired = false }); var currencySet = await Commander.Command <GetCurrencySetCommand>().Process( context.CommerceContext, context.GetPolicy <GlobalCurrencyPolicy>().DefaultCurrencySet).ConfigureAwait(false); var defaultCurrency = context.GetPolicy <GlobalEnvironmentPolicy>().DefaultCurrency; entityView.Properties.Add(new ViewProperty { Name = "InvoiceUnitPriceCurrency", RawValue = inventoryInformation?.InvoiceUnitPrice?.CurrencyCode ?? defaultCurrency, IsRequired = false, IsReadOnly = false, Policies = new List <Policy> { new AvailableSelectionsPolicy { List = currencySet.HasComponent <CurrenciesComponent>() ? currencySet.GetComponent <CurrenciesComponent>().Currencies .Select(c => new Selection { DisplayName = c.Code, Name = c.Code, IsDefault = c.Code.Equals(defaultCurrency, StringComparison.OrdinalIgnoreCase) }).ToList() : new List <Selection>() } } }); // Preorder fields entityView.Properties.Add(new ViewProperty { Name = nameof(PreorderableComponent.Preorderable), RawValue = inventoryInformation.GetValueOrDefault <PreorderableComponent, bool>(x => x.Preorderable, false), IsRequired = false }); entityView.Properties.Add(new ViewProperty { Name = nameof(PreorderableComponent.PreorderAvailabilityDate), RawValue = inventoryInformation.GetValueOrDefault <PreorderableComponent, DateTimeOffset?>(x => x.PreorderAvailabilityDate, string.Empty), OriginalType = typeof(DateTimeOffset).ToString(), IsRequired = false }); entityView.Properties.Add(new ViewProperty { Name = nameof(PreorderableComponent.PreorderLimit), RawValue = inventoryInformation.GetValueOrDefault <PreorderableComponent, int?>(x => x.PreorderLimit, null), OriginalType = typeof(int).ToString(), IsRequired = false }); // Backorder fields entityView.Properties.Add(new ViewProperty { Name = nameof(BackorderableComponent.Backorderable), RawValue = inventoryInformation.GetValueOrDefault <BackorderableComponent, bool>(x => x.Backorderable, false), IsRequired = false }); entityView.Properties.Add(new ViewProperty { Name = nameof(BackorderableComponent.BackorderAvailabilityDate), RawValue = inventoryInformation.GetValueOrDefault <BackorderableComponent, DateTimeOffset?>(x => x.BackorderAvailabilityDate, string.Empty), OriginalType = typeof(DateTimeOffset).ToString(), IsRequired = false }); entityView.Properties.Add(new ViewProperty { Name = nameof(BackorderableComponent.BackorderLimit), RawValue = inventoryInformation.GetValueOrDefault <BackorderableComponent, int?>(x => x.BackorderLimit, null), OriginalType = typeof(int).ToString(), IsRequired = false }); }
public async Task MakeOrder([FromBody] OrderClass orderClass) { List <Player> players = await _GAMEContext.Player.ToListAsync(); Player player = players.FirstOrDefault(m => m.Id == orderClass.PlayerId); if (player != null) { InventoryInformation inventoryInformation = player.Inventory; } int OrderMadeTo = 0; switch (player.PlayerRoleId) { case (int)Role.Retailer: OrderMadeTo = (int)_GAMEContext.GameTeamPlayerRelationship.Where(m => m.TeamId == player.GameTeamPlayerRelationship.FirstOrDefault().TeamId&& m.Player.PlayerRoleId == (int)Role.Wholesaler).FirstOrDefault().PlayerId; break; case (int)Role.Wholesaler: OrderMadeTo = (int)_GAMEContext.GameTeamPlayerRelationship.Where(m => m.TeamId == player.GameTeamPlayerRelationship.FirstOrDefault().TeamId&& m.Player.PlayerRoleId == (int)Role.Distributor).FirstOrDefault().PlayerId; break; case (int)Role.Distributor: OrderMadeTo = (int)_GAMEContext.GameTeamPlayerRelationship.Where(m => m.TeamId == player.GameTeamPlayerRelationship.FirstOrDefault().TeamId&& m.Player.PlayerRoleId == (int)Role.Factory).FirstOrDefault().PlayerId; break; case (int)Role.Factory: OrderMadeTo = 0; break; default: break; } GameTeamPlayerRelationship gameTeamPlayerRelationship = await _GAMEContext.GameTeamPlayerRelationship.FirstOrDefaultAsync(m => m.PlayerId == player.Id); int currentPeriod = gameTeamPlayerRelationship.Team.CurrentPeriod; PlayerTransactions playerTransactions = await _GAMEContext.PlayerTransactions.FirstOrDefaultAsync(m => m.OrderMadeFrom == player.Id && m.OrderMadePeriod == currentPeriod); if (playerTransactions == null) { playerTransactions = new PlayerTransactions(); _GAMEContext.PlayerTransactions.Add(playerTransactions); } playerTransactions.OrderMadeFrom = player.Id; playerTransactions.OrderMadeTo = OrderMadeTo; playerTransactions.OrderQty = orderClass.OrderQty; playerTransactions.GameId = gameTeamPlayerRelationship.GameId; playerTransactions.TeamId = gameTeamPlayerRelationship.TeamId; playerTransactions.OrderMadePeriod = gameTeamPlayerRelationship.Team.CurrentPeriod; playerTransactions.OrderReceivePeriod = gameTeamPlayerRelationship.Team.CurrentPeriod + 2; player.HasMadeDecision = true; await _GAMEContext.SaveChangesAsync(); if (await dataProvider.ShouldUpdateResults(gameTeamPlayerRelationship.TeamId)) { await dataProvider.UpdateResults(gameTeamPlayerRelationship.TeamId, gameTeamPlayerRelationship.Team.CurrentPeriod); } }
public override async Task <bool> Run(SellableItemInventorySetsArgument argument, CommercePipelineExecutionContext context) { AssociateStoreInventoryToSellablteItemBlock associateStoreInventoryToSellablteItemBlock = this; Condition.Requires(argument).IsNotNull(string.Format("{0}: The argument can not be null", argument)); string sellableItemId = argument.SellableItemId; CommerceEntity entity = await associateStoreInventoryToSellablteItemBlock._findEntityPipeline.Run(new FindEntityArgument(typeof(SellableItem), sellableItemId, false), context).ConfigureAwait(false); CommercePipelineExecutionContext executionContext; if (!(entity is SellableItem)) { executionContext = context; CommerceContext commerceContext = context.CommerceContext; string validationError = context.GetPolicy <KnownResultCodes>().ValidationError; string commerceTermKey = "EntityNotFound"; object[] args = new object[1] { argument.SellableItemId }; string defaultMessage = string.Format("Entity {0} was not found.", argument.SellableItemId); executionContext.Abort(await commerceContext.AddMessage(validationError, commerceTermKey, args, defaultMessage).ConfigureAwait(false), context); executionContext = null; return(false); } SellableItem sellableItem = entity as SellableItem; if ((string.IsNullOrEmpty(argument.VariationId)) & sellableItem.HasComponent <ItemVariationsComponent>()) { executionContext = context; executionContext.Abort(await context.CommerceContext.AddMessage(context.GetPolicy <KnownResultCodes>().ValidationError, "AssociateInventoryWithVariant", new object[0], "Can not associate inventory to the base sellable item. Use one of the variants instead.").ConfigureAwait(false), context); executionContext = null; return(false); } ItemVariationComponent sellableItemVariation = null; if (argument.VariationId != null) { sellableItemVariation = sellableItem.GetVariation(argument.VariationId); if (!string.IsNullOrEmpty(argument.VariationId) && sellableItemVariation == null) { executionContext = context; CommerceContext commerceContext = context.CommerceContext; string validationError = context.GetPolicy <KnownResultCodes>().ValidationError; string commerceTermKey = "ItemNotFound"; object[] args = new object[1] { argument.VariationId }; string defaultMessage = string.Format("Item '{0}' was not found.", argument.VariationId); executionContext.Abort(await commerceContext.AddMessage(validationError, commerceTermKey, args, defaultMessage).ConfigureAwait(false), context); executionContext = null; return(false); } } List <InventoryAssociation> inventoryAssociations = new List <InventoryAssociation>(); foreach (var inventorySetId in argument.InventorySetIds) { bool isUpdate = false; Random rnd = new Random(); InventoryInformation inventoryInformation = await associateStoreInventoryToSellablteItemBlock._getInventoryInformationCommand .Process(context.CommerceContext, inventorySetId, argument.SellableItemId, argument.VariationId, false) .ConfigureAwait(false); IFindEntitiesInListPipeline entitiesInListPipeline = associateStoreInventoryToSellablteItemBlock._findEntitiesInListPipeline; FindEntitiesInListArgument entitiesInListArgument1 = new FindEntitiesInListArgument(typeof(SellableItem), string.Format("{0}-{1}", "InventorySetToInventoryInformation", inventorySetId.SimplifyEntityName()), 0, int.MaxValue); entitiesInListArgument1.LoadEntities = false; CommercePipelineExecutionContext context1 = context; FindEntitiesInListArgument entitiesInListArgument2 = await entitiesInListPipeline.Run(entitiesInListArgument1, context1).ConfigureAwait(false); if (inventoryInformation != null && entitiesInListArgument2 != null) { List <ListEntityReference> entityReferences = entitiesInListArgument2.EntityReferences.ToList(); string id = inventoryInformation.Id; if (entityReferences != null && entityReferences.Any(er => er.EntityId == id)) { inventoryInformation.Quantity = rnd.Next(50); isUpdate = true; } } if (!isUpdate) { string inventorySetName = string.Format("{0}-{1}", inventorySetId.SimplifyEntityName(), sellableItem.ProductId); if (!string.IsNullOrEmpty(argument.VariationId)) { inventorySetName += string.Format("-{0}", argument.VariationId); } InventoryInformation inventoryInformation1 = new InventoryInformation(); inventoryInformation1.Id = string.Format("{0}{1}", CommerceEntity.IdPrefix <InventoryInformation>(), inventorySetName); inventoryInformation1.FriendlyId = inventorySetName; EntityReference entityReference1 = new EntityReference(inventorySetId, ""); inventoryInformation1.InventorySet = entityReference1; EntityReference entityReference2 = new EntityReference(argument.SellableItemId, ""); inventoryInformation1.SellableItem = entityReference2; string variationId = argument.VariationId; inventoryInformation1.VariationId = variationId; inventoryInformation1.Quantity = rnd.Next(50); inventoryInformation = inventoryInformation1; } inventoryInformation.GetComponent <TransientListMembershipsComponent>().Memberships.Add(CommerceEntity.ListName <InventoryInformation>()); PersistEntityArgument persistEntityArgument1 = await associateStoreInventoryToSellablteItemBlock._persistEntityPipeline.Run(new PersistEntityArgument((CommerceEntity)inventoryInformation), context).ConfigureAwait(false); RelationshipArgument relationshipArgument = await associateStoreInventoryToSellablteItemBlock._createRelationshipPipeline.Run(new RelationshipArgument(inventorySetId, inventoryInformation.Id, "InventorySetToInventoryInformation"), context).ConfigureAwait(false); InventoryAssociation inventoryAssociation = new InventoryAssociation() { InventoryInformation = new EntityReference(inventoryInformation.Id, ""), InventorySet = new EntityReference(inventorySetId, "") }; inventoryAssociations.Add(inventoryAssociation); } (sellableItemVariation != null ? sellableItemVariation.GetComponent <InventoryComponent>() : sellableItem.GetComponent <InventoryComponent>()).InventoryAssociations.AddRange(inventoryAssociations); PersistEntityArgument persistEntityArgument2 = await associateStoreInventoryToSellablteItemBlock._persistEntityPipeline.Run(new PersistEntityArgument(sellableItem), context).ConfigureAwait(false); return(true); }
public async Task AddPlayers([FromBody] AddPlayerClass addPlayerClass) { try { List <PlayerClass> players = addPlayerClass.Players; var GroupedPlayer = players.GroupBy(u => u.Team).Select(grp => grp.ToList()).ToList(); Game game; if (addPlayerClass.GameId == null) { List <int> demandData = new List <int>(); for (int i = 1; i <= 40; i++) { int demand = (i <= 6) ? 4 : 8; demandData.Add(demand); } game = new Game { Name = addPlayerClass.GameName, MaxPeriod = 40, DeliveryDelay = 2, FacilitatorId = addPlayerClass.FacilId, DemandInformation = Newtonsoft.Json.JsonConvert.SerializeObject(demandData), GameUrl = "http://winegame.edventist.com/" }; _GAMEContext.Game.Add(game); await _GAMEContext.SaveChangesAsync(); } else { game = await _GAMEContext.Game.Where(m => m.Id == (int)addPlayerClass.GameId).FirstOrDefaultAsync(); } foreach (List <PlayerClass> group in GroupedPlayer) { Player groupPlayer = await _GAMEContext.Player.Where(m => m.Id == group.FirstOrDefault().Id).FirstOrDefaultAsync(); await _GAMEContext.GameTeamPlayerRelationship.ToListAsync(); await _GAMEContext.Team.ToListAsync(); Team team = new Team(); if (groupPlayer != null) { team = groupPlayer.GameTeamPlayerRelationship.FirstOrDefault().Team; team.Name = group.FirstOrDefault().Team; } else { team = new Team { Name = group.FirstOrDefault().Team, CurrentOrder = 4, CurrentPeriod = 2 }; _GAMEContext.Team.Add(team); } await _GAMEContext.SaveChangesAsync(); foreach (PlayerClass newPlayer in group) { Player player = await _GAMEContext.Player.Where(m => m.Id == newPlayer.Id).FirstOrDefaultAsync(); if (player == null) { player = new Player { FirstName = newPlayer.FirstName, LastName = newPlayer.LastName, Email = newPlayer.Email, HasMadeDecision = false }; InventoryInformation inventoryInformation = new InventoryInformation { CurrentInventory = 50, Backlogs = 0, IncomingInventory = 4, TotalCost = 0, NewOrder = 4 }; switch (newPlayer.Role) { case "Retailer": player.PlayerRoleId = (int)Role.Retailer; break; case "Distributor": player.PlayerRoleId = (int)Role.Distributor; break; case "Wholesaler": player.PlayerRoleId = (int)Role.Wholesaler; break; case "Factory": player.PlayerRoleId = (int)Role.Factory; break; default: break; } var userName = ""; userName = (newPlayer.FirstName.Length > 3 ? userName += newPlayer.FirstName.Substring(0, 3) : userName += newPlayer.FirstName); userName = (newPlayer.LastName.Length > 3 ? userName += newPlayer.LastName.Substring(0, 3) : userName += newPlayer.LastName); player.Username = userName.ToLower(); player.Password = userName.ToLower(); _GAMEContext.InventoryInformation.Add(inventoryInformation); _GAMEContext.Player.Add(player); await _GAMEContext.SaveChangesAsync(); player.InventoryId = inventoryInformation.Id; GameTeamPlayerRelationship gameTeamPlayerRelationship = new GameTeamPlayerRelationship { GameId = game.Id, TeamId = team.Id, PlayerId = player.Id }; _GAMEContext.GameTeamPlayerRelationship.Add(gameTeamPlayerRelationship); await _GAMEContext.SaveChangesAsync(); Results results = new Results { GameTeamPlayerRelationshipId = gameTeamPlayerRelationship.Id, PreviousOrder = 4, Inventory = player.Inventory.CurrentInventory, IncomingInventory = 4, TotalCost = 0, Period = 2, OrderQty = 4, SentQty = 4 }; _GAMEContext.Results.Add(results); await dataProvider.SendEmail(player); } else { player.FirstName = newPlayer.FirstName; player.LastName = newPlayer.LastName; player.Email = newPlayer.Email; } await _GAMEContext.SaveChangesAsync(); } } } catch (Exception ex) { Console.Write(ex.ToString()); } }
// PUT: api/Picking/5 public void Put(int id, [FromBody] InventoryInformation value) { }
// POST: api/Picking public void Post([FromBody] InventoryInformation value) { }
private void TransformCore(CommerceContext commerceContext, string[] rawFields, InventoryInformation item) { var inventorySetName = rawFields[InventoryIdIndex]; var productId = rawFields[ProductIdIndex]; int.TryParse(rawFields[QuantityIndex], out int quantity); string str = inventorySetName + "-" + productId; //if (!string.IsNullOrEmpty(arg.VariationId)) str = str + "-" + arg.VariationId; item.Id = CommerceEntity.IdPrefix <InventoryInformation>() + str; item.FriendlyId = str; item.InventorySet = new EntityReference(inventorySetName.ToEntityId <InventorySet>(), ""); item.SellableItem = new EntityReference(productId.ToEntityId <SellableItem>(), ""); //item.VariationId = arg.VariationId; item.Quantity = quantity; var component = item.GetComponent <ListMembershipsComponent>(); component.Memberships.Add(CommerceEntity.ListName <InventoryInformation>()); var component1 = item.GetComponent <PreorderableComponent>(); //component1.Preorderable = result1; //component1.PreorderAvailabilityDate = new DateTimeOffset?(); //component1.PreorderLimit = new int?(0); var component2 = item.GetComponent <BackorderableComponent>(); //component2.Backorderable = result3; //component2.BackorderAvailabilityDate = new DateTimeOffset?(); //component2.BackorderLimit = new int?(0); }