public static void InventoryProductCodeLengthShouldBe12CharactersLong(this UpdateInventory updateInventory) { if (updateInventory.ProductCode.Length != 12) { throw new InventoryRuleViolationException("Inventory ProductCode should be 12 characters long."); } }
public static void InventoryPriceShouldBeZerorOrLarger(this UpdateInventory updateInventory) { if (updateInventory.UnitPrice < 0) { throw new InventoryRuleViolationException("UnitPrice should be larger than 0."); } }
//Método responsável por Atualizar quantidade em estoque por produto public async Task <HttpResponseMessage> AtualizarQuantidadeEstoque(int _skuId, int _onHand) { Log log = new Log(); try { string warehouseId = ConfigurationManager.AppSettings["warehouseId"]; string accountName = ConfigurationManager.AppSettings["accountName"]; log.WriteLogEstoque("Atualizando quantidade em estoque para o Item " + _skuId + " - Estoque " + warehouseId); UpdateInventory updateInventory = new UpdateInventory(); updateInventory.quantity = _onHand; string jsonUpdateInventory = JsonUtil.ConvertToJsonString(updateInventory); string _param = "?an=" + accountName; string uri = "api/logistics/pvt/inventory/skus/" + _skuId + "/warehouses/" + warehouseId + _param; //Log.WriteLog("URI: "+uri); HttpResponseMessage response = await BuildClientLogistics().PutAsync(uri, new StringContent(jsonUpdateInventory, UnicodeEncoding.UTF8, "application/json")); return(response); } catch (HttpRequestException e) { log.WriteLogEstoque("Exception AtualizarQuantidadeEstoque " + e.InnerException.Message); throw; } }
static void sampleUpdateAsync(int listingId = 792035687, string sellPrice = "1350", string currentQty = "1") { var client = new RestClient(); client.BaseUrl = new System.Uri("https://openapi.etsy.com/v2/listings/" + listingId + "/inventory?api_key=3ptctueuc44gh9e3sny1oix5&write_missing_inventory=true"); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); var inventoryVariations = JsonConvert.DeserializeObject <GetInventory>(response.Content); if (inventoryVariations.results.products.Count == 1) { List <UpdateInventory> updateInventoryList = new List <UpdateInventory>(); UpdateInventory updateInventory = new UpdateInventory(); updateInventory.product_id = inventoryVariations.results.products[0].product_id; updateInventory.offerings.Add(new UpdateOffering()); updateInventory.offerings[0].offering_id = inventoryVariations.results.products[0].offerings[0].offering_id; updateInventory.offerings[0].price = (Convert.ToDouble(sellPrice) * 1.15).ToString(); updateInventory.offerings[0].quantity = int.Parse(currentQty); updateInventoryList.Add(updateInventory); var client1 = new RestClient("https://openapi.etsy.com/v2/listings/" + listingId + "/inventory"); var request1 = new RestRequest(Method.PUT); request1.AddHeader("Authorization", "OAuth " + OAuthSignatureGenerator.GetAuthorizationHeaderValue(new Uri("https://openapi.etsy.com/v2/listings/" + listingId + "/inventory"), JsonConvert.SerializeObject(updateInventoryList))); request1.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request1.AddParameter("products", JsonConvert.SerializeObject(updateInventoryList)); IRestResponse response1 = client1.Execute(request1); WriteToFile(response1.Content); } }
public async Task <IActionResult> UpdateInventory(UpdateInventory command) { try { if (ModelState.IsValid) { await commandExecutor.RunAsync(command); return(Ok()); } return(BadRequest()); } catch (InventoryRuleViolationException ex) { return(StatusCode(StatusCodes.Status409Conflict, new InventoryRuleViolation(ex.Message))); } catch (Exception ex) { string errorMessage = "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."; Log.Error(ex, errorMessage); ModelState.AddModelError("ErrorMessage", errorMessage); return(StatusCode(StatusCodes.Status500InternalServerError)); } return(Ok()); }
//Método responsável por Atualizar quantidade em estoque por produto public async Task <HttpResponseMessage> AtualizarQuantidadeEstoque(string _skuId, int _onHand) { Log log = new Log(); try { log.WriteLogEstoque("Atualizando quantidade em estoque para o Item " + _skuId); UpdateInventory updateInventory = new UpdateInventory(); List <Skus> listSku = new List <Skus>(); Skus sku = new Skus(); sku.IdSku = _skuId; sku.Quantity = _onHand; listSku.Add(sku); //updateInventory.SkuList = listSku; string jsonUpdateInventory = JsonUtil.ConvertToJsonString(listSku); string uri = "api/Stock"; HttpResponseMessage response = await BuildClient().PutAsync(uri, new StringContent(jsonUpdateInventory, UnicodeEncoding.UTF8, "application/json")); return(response); } catch (HttpRequestException e) { log.WriteLogEstoque("Exception AtualizarQuantidadeEstoque " + e.InnerException.Message); throw; } }
public static void InventoryQuantityShouldBeZeroOrLarger(this UpdateInventory updateInventory) { if (updateInventory.Quantity < 0) { throw new InventoryRuleViolationException("Quantity should be larger than 0."); } }
public static Inventory ToModel(this UpdateInventory command) { return new Inventory( command.ProductCode, command.Description, command.Quantity, command.UnitPrice); }
public UpdateInventoryTests() { _updateAgedBrie = Substitute.For <IUpdateAgedBrie>(); _updateBackStage = Substitute.For <IUpdateBackStageItems>(); _updateConjuredItems = Substitute.For <IUpdateConjuredItems>(); _updateOrdinaryItems = Substitute.For <IUpdateOrdinaryItems>(); _sut = new UpdateInventory(_updateBackStage, _updateAgedBrie, _updateConjuredItems, _updateOrdinaryItems); }
private static void DefaultETWTracking() { UpdateInventory wf = new UpdateInventory(); wf.ArgSalesOrderId = 43687; WorkflowInvoker instance = new WorkflowInvoker(wf); instance.Extensions.Add(new EtwTrackingParticipant()); instance.Invoke(); }
public static InventoryUpdated ToEvent(this UpdateInventory command) { return(new InventoryUpdated() { ProductCode = command.ProductCode, Description = command.Description, Quantity = command.Quantity, UnitPrice = command.UnitPrice }); }
public UpdateInventoryViewModel(Inventory inventory, EFDbContext context) { _inventory = inventory; repo = new EFRepository <Inventory>(context); _invType = new EFRepository <InventoryType>(context); type = _inventory.InventoryTypeId; Window window = new UpdateInventory(this); window.ShowDialog(); }
private void RunProgram(List <Item> items) { var updateAgedBrie = new UpdateAgedBrie(new IncreaseQuality(), new DecreaseSellIn()); var updateBackStageItems = new UpdateBackStageItems(new IncreaseQuality(), new DecreaseSellIn()); var updateOrdinaryItems = new UpdateOrdinaryItem(new DecreaseQuality(), new DecreaseSellIn()); var updateConjuredItems = new UpdateConjuredItems(new DecreaseQuality(), new DecreaseSellIn()); var updateInventory = new UpdateInventory(updateBackStageItems, updateAgedBrie, updateConjuredItems, updateOrdinaryItems); var app = new Program(items, updateInventory); app.UpdateQuality(); }
/// <summary> /// /// </summary> /// <param name="KinectSensor">The <see cref="Microsoft.Kinect.KinectSensor"/> associated to the game</param> public GameController(Microsoft.Kinect.KinectSensor KinectSensor) { attRandom = new Random(1); attKinectInterrogator = new KinectInterrogator( KinectSensor, REFRESH_TIME ); attDataBase = new Helpers.DBHelper(); attResumeGame = new ResumeGame(); attUnloadGame = new UnloadGame(); attUpdateInventory = new UpdateInventory(); attNotifyItemException = new NotifyItemException(); attKinectInterrogator.PlayerEnterKinectSensorEvent = HandlePlayerEnterKinectSensor; attKinectInterrogator.PlayerLeaveKinectSensorEvent = HandlePlayerLeaveKinectSensor; attKinectInterrogator.BarCodeRecognizedEvent = HandleBarCodeRecognized; }
private static void CustomEventTracking() { EventTrackingParticipant tp = new EventTrackingParticipant(); tp.Received = tr => Console.WriteLine("{0:D2} {1:HH:mm:ss.ffffff} {2}", tr.RecordNumber, tr.EventTime, tr.GetType().Name); UpdateInventory wf = new UpdateInventory(); wf.ArgSalesOrderId = 43687; WorkflowInvoker instance = new WorkflowInvoker(wf); instance.Extensions.Add(tp); instance.Invoke(); }
static void updateInventory(int listingId, string sellPrice, string currentQty, string sku) { var client = new RestClient(); client.BaseUrl = new Uri("https://openapi.etsy.com/v2/listings/" + listingId + "/inventory?api_key=3ptctueuc44gh9e3sny1oix5&write_missing_inventory=true"); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); CheckRequestThrottleLimit(); try { var inventoryVariations = JsonConvert.DeserializeObject <GetInventory>(response.Content); if (inventoryVariations.results.products.Count == 1) { List <UpdateInventory> updateInventoryList = new List <UpdateInventory>(); UpdateInventory updateInventory = new UpdateInventory(); updateInventory.product_id = inventoryVariations.results.products[0].product_id; updateInventory.offerings.Add(new UpdateOffering()); updateInventory.offerings[0].offering_id = inventoryVariations.results.products[0].offerings[0].offering_id; updateInventory.offerings[0].price = (Convert.ToDouble(sellPrice) * 1.15).ToString(); updateInventory.offerings[0].quantity = int.Parse(currentQty); updateInventory.sku = sku; updateInventoryList.Add(updateInventory); var client1 = new RestClient("https://openapi.etsy.com/v2/listings/" + listingId + "/inventory"); var request1 = new RestRequest(Method.PUT); request1.AddHeader("Authorization", "OAuth " + OAuthSignatureGenerator.GetAuthorizationHeaderValue(client1.BaseUrl, JsonConvert.SerializeObject(updateInventoryList))); request1.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request1.AddParameter("products", JsonConvert.SerializeObject(updateInventoryList)); IRestResponse response1 = client1.Execute(request1); CheckRequestThrottleLimit(); WriteToFile("Stock Item is Updated with Listing ID: " + listingId + " (" + sku + ")"); Listings = Listings + sku + ", "; //WriteToFile(response1.Content); } } catch (Exception e) { WriteToFile("Error for " + listingId + "-----" + e.StackTrace); } }
private static void CustomTrackingWithProfileAppConfig() { TrackingProfileLoader config = new TrackingProfileLoader("MyTrackingProfile"); FileTrackingParticipant tp = new FileTrackingParticipant(); tp.TrackingProfile = config.Profile; UpdateInventory wf = new UpdateInventory(); wf.ArgSalesOrderId = 43687; WorkflowInvoker instance = new WorkflowInvoker(wf); instance.Extensions.Add(tp); instance.Invoke(); tp.Stop(); }
static void Main(string[] args) { System.Console.WriteLine("OMGHAI!"); var updateAgedBrie = new UpdateAgedBrie(new IncreaseQuality(), new DecreaseSellIn()); var updateBackStageItems = new UpdateBackStageItems(new IncreaseQuality(), new DecreaseSellIn()); var updateOrdinaryItems = new UpdateOrdinaryItem(new DecreaseQuality(), new DecreaseSellIn()); var updateConjuredItems = new UpdateConjuredItems(new DecreaseQuality(), new DecreaseSellIn()); var updateInventory = new UpdateInventory(updateBackStageItems, updateAgedBrie, updateConjuredItems, updateOrdinaryItems); var app = new Program(new List <Item> { new Item { Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20 }, new Item { Name = "Aged Brie", SellIn = 2, Quality = 0 }, new Item { Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7 }, new Item { Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80 }, new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 15, Quality = 20 }, new Item { Name = "Conjured Mana Cake", SellIn = 3, Quality = 6 } }, updateInventory); app.UpdateQuality(); System.Console.ReadKey(); }
public async Task <IActionResult> Edit([FromForm] InventoryEditViewModel inputModel) { if (ModelState.IsValid) { return(await resiliencyHelper.ExecuteResilient(async() => { try { var command = new UpdateInventory(Guid.NewGuid(), Guid.NewGuid(), inputModel.Inventory.ProductCode, inputModel.Inventory.Description, inputModel.Inventory.Quantity, inputModel.Inventory.UnitPrice); await inventoryManagementAPI.UpdateInventory(command); } catch (ApiException ex) { if (ex.StatusCode == HttpStatusCode.Conflict) { var content = await ex.GetContentAsAsync <InventoryRuleViolation>(); inputModel.Error = content.ErrorMessage; return View("Edit", inputModel); } } return RedirectToAction("Index"); }, View("Offline", new InventoryOfflineViewModel()))); } else { return(View("Edit", inputModel)); } }
public async Task UpdateInventory(UpdateInventory command) { await restClient.UpdateInventory(command); }
private static void ETWTrackingWithProfile(Int32 profileNumber) { UpdateInventory wf = new UpdateInventory(); wf.ArgSalesOrderId = 43687; WorkflowInvoker instance = new WorkflowInvoker(wf); EtwTrackingParticipant tp = new EtwTrackingParticipant(); switch (profileNumber) { case 1: //select workflow instance states tp.TrackingProfile = new TrackingProfile { Name = "MyTrackingProfile", Queries = { new WorkflowInstanceQuery { States = { WorkflowInstanceStates.Started, WorkflowInstanceStates.Completed, } } } }; break; case 2: //all workflow instance states tp.TrackingProfile = new TrackingProfile { Name = "MyTrackingProfile", Queries = { new WorkflowInstanceQuery { States ={ "*" } } } }; break; case 3: //selected activity states tp.TrackingProfile = new TrackingProfile { Name = "MyTrackingProfile", Queries = { new WorkflowInstanceQuery { States ={ "*" } }, new ActivityStateQuery { States = { ActivityStates.Executing, ActivityStates.Closed } } } }; break; case 4: //Activity states for selected activities with //argument extraction tp.TrackingProfile = new TrackingProfile { Name = "MyTrackingProfile", Queries = { new WorkflowInstanceQuery { States = { WorkflowInstanceStates.Started, WorkflowInstanceStates.Completed, } }, new ActivityStateQuery { ActivityName = "UpdateInventory", States = { ActivityStates.Executing }, Arguments = { "*" } }, new ActivityStateQuery { ActivityName = "InsertTranHistory", States = { "*" } }, new ActivityStateQuery { ActivityName = "UpdateProductInventory", States = { ActivityStates.Executing }, Arguments = { "SalesDetail" }, QueryAnnotations = { { "Threading Model", "Asynchronous update"} } }, new ActivityStateQuery { ActivityName = "UpdateProductInventory", States = { ActivityStates.Closed } } } }; break; case 5: //Activity states for selected activities with //argument extraction and selected activity scheduled query tp.TrackingProfile = new TrackingProfile { Name = "MyTrackingProfile", Queries = { new WorkflowInstanceQuery { States = { WorkflowInstanceStates.Started, WorkflowInstanceStates.Completed, } }, new ActivityStateQuery { ActivityName = "UpdateInventory", States = { ActivityStates.Executing }, Arguments = { "*" } }, new ActivityStateQuery { ActivityName = "InsertTranHistory", States = { "*" } }, new ActivityStateQuery { ActivityName = "UpdateProductInventory", States = { ActivityStates.Executing }, Arguments = { "SalesDetail" }, QueryAnnotations = { { "Threading Model", "Asynchronous update"} } }, new ActivityStateQuery { ActivityName = "UpdateProductInventory", States = { ActivityStates.Closed } }, new ActivityScheduledQuery { ChildActivityName = "UpdateProductInventory" } } }; break; case 6: //Activity states for selected activities with //argument extraction and selected activity scheduled query //also adds Custom Tracking Records tp.TrackingProfile = new TrackingProfile { Name = "MyTrackingProfile", Queries = { new WorkflowInstanceQuery { States = { WorkflowInstanceStates.Started, WorkflowInstanceStates.Completed, } }, new ActivityStateQuery { ActivityName = "UpdateInventory", States = { ActivityStates.Executing }, Arguments = { "*" } }, new ActivityStateQuery { ActivityName = "InsertTranHistory", States = { "*" } }, new ActivityStateQuery { ActivityName = "UpdateProductInventory", States = { ActivityStates.Executing }, Arguments = { "SalesDetail" }, QueryAnnotations = { { "Threading Model", "Asynchronous update"} } }, new ActivityStateQuery { ActivityName = "UpdateProductInventory", States = { ActivityStates.Closed } }, new ActivityScheduledQuery { ChildActivityName = "UpdateProductInventory" }, new CustomTrackingQuery { ActivityName = "*", Name = "*" } } }; break; default: break; } instance.Extensions.Add(tp); instance.Invoke(); }