public async Task <int> Add(Fulfillment fulfillment) { var cmd = QueriesCreatingHelper.CreateQueryInsert(fulfillment); cmd += ";SELECT LAST_INSERT_ID();"; return((await DALHelper.ExecuteQuery <int>(cmd, dbTransaction: DbTransaction, connection: DbConnection)).First()); }
public async Task <IActionResult> CreateFulfillment([FromBody] FulfillmentDetailModel model) { var response = ""; try { string shopifyurl = $"https://{model.shopifyurl}.myshopify.com"; var locationservice = new LocationService(shopifyurl, model.token); var locations = await locationservice.ListAsync(); var lid = locations.Where(x => x.Name.ToLower() == "parco").FirstOrDefault(); var service = new FulfillmentService(shopifyurl, model.token); var fulfillment = new Fulfillment() { TrackingCompany = model.trackingCompany, TrackingUrl = model.trackingUrl, TrackingNumber = model.trackingNumber, LocationId = lid.Id }; fulfillment = await service.CreateAsync(model.orderId, fulfillment); response = JsonConvert.SerializeObject(fulfillment); } catch (Exception ex) { // response = ex.InnerException?.Message.ToString(); return(BadRequest(ex.Message)); } return(Ok(response)); }
public void GetFulfillment() { moq::Mock <Fulfillments.FulfillmentsClient> mockGrpcClient = new moq::Mock <Fulfillments.FulfillmentsClient>(moq::MockBehavior.Strict); GetFulfillmentRequest request = new GetFulfillmentRequest { FulfillmentName = FulfillmentName.FromProject("[PROJECT]"), }; Fulfillment expectedResponse = new Fulfillment { FulfillmentName = FulfillmentName.FromProject("[PROJECT]"), DisplayName = "display_name137f65c2", GenericWebService = new Fulfillment.Types.GenericWebService(), Enabled = true, Features = { new Fulfillment.Types.Feature(), }, }; mockGrpcClient.Setup(x => x.GetFulfillment(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); FulfillmentsClient client = new FulfillmentsClientImpl(mockGrpcClient.Object, null); Fulfillment response = client.GetFulfillment(request.Name); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public static async Task <Fulfillment> FulfillOrderPartially(IConfiguration appConfig, long orderId, long lineItemId, int lineItemQuantity, string trackingNumber, bool notifyCustomer) { // get shopify configuration parameters var config = new MyConfiguration(appConfig); string shopifyDomain = config.GetString("ShopifyDomain"); string shopifyAPIPassword = config.GetString("ShopifyAPIPassword"); var service = new FulfillmentService(shopifyDomain, shopifyAPIPassword); var fulfillment = new Fulfillment() { TrackingCompany = "Posten", TrackingUrl = $"https://sporing.posten.no/sporing.html?q={trackingNumber}", TrackingNumber = trackingNumber, LineItems = new List <LineItem>() { new LineItem() { Id = lineItemId, Quantity = lineItemQuantity } } }; fulfillment = await service.CreateAsync(orderId, fulfillment, notifyCustomer); return(fulfillment); }
public async Task AddValidTradeToQueue() { var context = Helpers.GetMockContext(); var stateManager = new MockReliableStateManager(); var service = new Fulfillment(context, stateManager); var ask = new Order("user1", CurrencyPair.GBPUSD, 10, 10); var bid = new Order("user2", CurrencyPair.GBPUSD, 10, 10); var settlement = new Order(ask.Pair, bid.Amount, ask.Price); var request = new TradeRequestModel { Ask = ask, Bid = bid, Settlement = settlement }; var tradeId = await service.AddTradeAsync(request); var expected = new Trade(tradeId, ask, bid, settlement); var queue = await stateManager.TryGetAsync <IReliableConcurrentQueue <Trade> >(Fulfillment.TradeQueueName); var actual = (await queue.Value.TryDequeueAsync(new MockTransaction(stateManager, 1))).Value; Assert.True(expected.Equals(actual)); }
public async Task <int> Update(Fulfillment fulfillment) { var cmd = QueriesCreatingHelper.CreateQueryUpdate(fulfillment); var rs = await DALHelper.Execute(cmd, dbTransaction : DbTransaction, connection : DbConnection); return(rs == 0 ? -1 : 0); }
protected override async Task Handle(ShopifyOrderFulfilled request, CancellationToken cancellationToken) { _logger.LogInformation("Fulfilling Order in Shopify: {orderid}", request.ShopifyOrderId); try { var locationService = new LocationService(_config.ShopUrl, _config.AccessToken); IEnumerable <Location> locations = await locationService.ListAsync(cancellationToken); Location defaultLocation = locations.FirstOrDefault(); var fulfillmentService = new FulfillmentService(_config.ShopUrl, _config.AccessToken); var fulfillment = new Fulfillment() { TrackingCompany = "Willards Shipping Services", TrackingUrl = $"https://willards.com/{request.ShopifyOrderId}", TrackingNumber = request.ShopifyOrderId.ToString(), LocationId = defaultLocation.Id }; Fulfillment fulfillmentResult = await fulfillmentService.CreateAsync(request.ShopifyOrderId, fulfillment, cancellationToken); } catch (ShopifyException e) { _logger.LogError(e, "Couldn't complete the fulfillment"); throw; } }
/// <summary> /// Fills the fulfillment table initially. /// </summary> /// <param name="projectId">The project identifier.</param> /// <param name="allProjectProducts">All project products.</param> /// <param name="allProjectCriterions">All project criterions.</param> /// Erstellt von Joshua Frey, am 28.12.2015 /// <exception cref="NWATException"> /// </exception> public void FillFulfillmentTableInitially(int projectId, List <ProjectProduct> allProjectProducts, List <ProjectCriterion> allProjectCriterions) { foreach (ProjectProduct projProd in allProjectProducts) { int productId = projProd.Product_Id; if (allProjectCriterions.Count == 0) { throw new NWATException(MessageGivenParamListIsEmpty("Projektkriterien Liste")); } else if (allProjectProducts.Count == 0) { throw new NWATException(MessageGivenParamListIsEmpty("Projektprodukte Liste")); } else { foreach (ProjectCriterion projCrit in allProjectCriterions) { int criterionId = projCrit.Criterion_Id; Fulfillment insertFulfillment = new Fulfillment() { Project_Id = projectId, Product_Id = productId, Criterion_Id = criterionId, Fulfilled = false, Comment = null }; InsertFullfillmentInDb(insertFulfillment); } } } }
public async stt::Task GetFulfillmentRequestObjectAsync() { moq::Mock <Fulfillments.FulfillmentsClient> mockGrpcClient = new moq::Mock <Fulfillments.FulfillmentsClient>(moq::MockBehavior.Strict); GetFulfillmentRequest request = new GetFulfillmentRequest { FulfillmentName = FulfillmentName.FromProject("[PROJECT]"), }; Fulfillment expectedResponse = new Fulfillment { FulfillmentName = FulfillmentName.FromProject("[PROJECT]"), DisplayName = "display_name137f65c2", GenericWebService = new Fulfillment.Types.GenericWebService(), Enabled = true, Features = { new Fulfillment.Types.Feature(), }, }; mockGrpcClient.Setup(x => x.GetFulfillmentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Fulfillment>(stt::Task.FromResult(expectedResponse), null, null, null, null)); FulfillmentsClient client = new FulfillmentsClientImpl(mockGrpcClient.Object, null); Fulfillment responseCallSettings = await client.GetFulfillmentAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Fulfillment responseCancellationToken = await client.GetFulfillmentAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public Fulfillment Put(UpdateFulfillment request) { Fulfillment fulfillmentToUpdate = null; DbConnExecTransaction((con) => { fulfillmentToUpdate = con.GetById <Fulfillment>(request.Id); if (request.Status == "Start" && !String.IsNullOrEmpty(fulfillmentToUpdate.Fulfiller)) { throw new Exception("Already Started!"); } fulfillmentToUpdate.Status = request.Status; fulfillmentToUpdate.Fulfiller = base.SessionAs <AuthUserSession>().UserName; con.Update <Fulfillment>(fulfillmentToUpdate); }); //Refresh FulfillmentGrid var hub = GlobalHost.ConnectionManager.GetHubContext("FulfillmentGridHub"); if (hub != null) { hub.Clients.All.updateGrid(fulfillmentToUpdate); } //Publish Message RedisExec((redisCon) => redisCon.PublishMessage("FulfillmentUpdate", fulfillmentToUpdate.ToJson())); return(fulfillmentToUpdate); }
public async Task <IActionResult> CreateSingleFulfillment([FromBody] FulfillmentDetailModel model) { var response = ""; try { var service = new FulfillmentService(model.shopifyurl, model.token); var fulfillment = new Fulfillment() { TrackingCompany = "Jack Black's Pack, Stack and Track", TrackingUrl = "https://example.com/123456789", TrackingNumber = "123456789", // LineItems = new List<LineItem>() //{ // new LineItem() // { // Id = lineItemId // } //} }; fulfillment = await service.CreateAsync(model.orderId, fulfillment); response = "Single Fulfillment is created successfuly!"; } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok(response)); }
public List <Fulfillment> Get(Fulfillment request) { var ev = OrmLiteConfig.DialectProvider.ExpressionVisitor <Fulfillment>(); ev.Where(f => f.Status != "Completed").OrderBy(f => f.Id); var fulfillments = DbConnExec((con) => con.Select <Fulfillment>(ev)); return(fulfillments); }
/// <summary> /// Method to fulfill an order if no fulfillment has been created for this orderId /// </summary> /// <param name="shop">web url to store</param> /// <param name="token">store authentication token</param> /// <param name="orderId">Id of the order to be query</param> /// <param name="labelNumbers">a string contains label number(s) to be added to the fulfillment </param> /// <returns>fulfillment id as string</returns> public async Task <string> NewFulfillment(string shop, string token, string orderId, string labelNumbers) { var trackingCompany = ""; var trackingUrl = ""; DbEngine conn = new DbEngine(); int cCode = conn.GetIntergerValues(shop, "CountryCode"); switch (cCode) { case 1: trackingCompany = "Fastway Couriers (Australia)"; trackingUrl = "https://www.fastway.com.au/tools/track?l="; break; case 6: trackingCompany = "Fastway Couriers (NZ) Ltd."; trackingUrl = "https://www.fastway.co.nz/track/track-your-parcel?l="; break; } //creating template for fulfillment details var fulfillment = new Fulfillment() { TrackingCompany = trackingCompany, }; if (labelNumbers.Contains(",")) {// if there are more than one labels //list of tracking numbers List <string> trackingNumbers = labelNumbers.Split(',').ToList(); fulfillment.TrackingNumbers = trackingNumbers; //list of tracking urls List <string> trackingUrls = new List <string>(); foreach (string number in trackingNumbers) { trackingUrls.Add(trackingUrl + number); } fulfillment.TrackingUrls = trackingUrls; } else {// only one tracking number fulfillment.TrackingNumber = labelNumbers; fulfillment.TrackingUrl = trackingUrl + labelNumbers; } //fulfillmentservice object to create fulfillment var service = new FulfillmentService(shop, token); //creating fulfillment to fulfill order fulfillment = await service.CreateAsync(Convert.ToInt64(orderId), fulfillment, true); //returning fulfillment id return(fulfillment.Id.ToString()); }
/// <summary>Snippet for GetFulfillment</summary> public void GetFulfillment() { // Snippet: GetFulfillment(string, CallSettings) // Create client FulfillmentsClient fulfillmentsClient = FulfillmentsClient.Create(); // Initialize request argument(s) string name = "projects/[PROJECT]/agent/fulfillment"; // Make the request Fulfillment response = fulfillmentsClient.GetFulfillment(name); // End snippet }
/// <summary>Snippet for GetFulfillment</summary> public void GetFulfillmentResourceNames() { // Snippet: GetFulfillment(FulfillmentName, CallSettings) // Create client FulfillmentsClient fulfillmentsClient = FulfillmentsClient.Create(); // Initialize request argument(s) FulfillmentName name = FulfillmentName.FromProject("[PROJECT]"); // Make the request Fulfillment response = fulfillmentsClient.GetFulfillment(name); // End snippet }
/// <summary>Snippet for UpdateFulfillment</summary> public void UpdateFulfillment() { // Snippet: UpdateFulfillment(Fulfillment, FieldMask, CallSettings) // Create client FulfillmentsClient fulfillmentsClient = FulfillmentsClient.Create(); // Initialize request argument(s) Fulfillment fulfillment = new Fulfillment(); FieldMask updateMask = new FieldMask(); // Make the request Fulfillment response = fulfillmentsClient.UpdateFulfillment(fulfillment, updateMask); // End snippet }
public async Task <int> Delete(Fulfillment fulfillment) { var cmd = $@"UPDATE `fulfillment` SET `is_deleted` = 1, `modified_by` = {fulfillment.ModifiedBy}, `modified_date` = '{fulfillment.ModifiedDate?.ToString("yyyyMMddHHmmss")}' WHERE `id` = {fulfillment.Id}"; var rs = await DALHelper.Execute(cmd, dbTransaction : DbTransaction, connection : DbConnection); return(rs == 0 ? -1 : 0); }
/* * Private section */ /// <summary> /// Checks if fulfillments are equal. /// </summary> /// <param name="fulfillmentOne">The fulfillment one.</param> /// <param name="fulfillmentTwo">The fulfillment two.</param> /// <returns> /// bool if fulfillments are equal. /// </returns> /// Erstellt von Joshua Frey, am 29.12.2015 private bool CheckIfEqualFulfillments(Fulfillment fulfillmentOne, Fulfillment fulfillmentTwo) { bool sameProjectId = fulfillmentOne.Project_Id == fulfillmentTwo.Project_Id; bool sameProductId = fulfillmentOne.Product_Id == fulfillmentTwo.Product_Id; bool sameCriterionId = fulfillmentOne.Criterion_Id == fulfillmentTwo.Criterion_Id; bool sameDegreeOfFulfillment = fulfillmentOne.Fulfilled == fulfillmentTwo.Fulfilled; bool sameComment = fulfillmentOne.Comment == fulfillmentTwo.Comment; return(sameComment && sameCriterionId && sameDegreeOfFulfillment && sameProductId && sameProjectId); }
/// <summary>Snippet for GetFulfillmentAsync</summary> public async Task GetFulfillmentResourceNamesAsync() { // Snippet: GetFulfillmentAsync(FulfillmentName, CallSettings) // Additional: GetFulfillmentAsync(FulfillmentName, CancellationToken) // Create client FulfillmentsClient fulfillmentsClient = await FulfillmentsClient.CreateAsync(); // Initialize request argument(s) FulfillmentName name = FulfillmentName.FromProject("[PROJECT]"); // Make the request Fulfillment response = await fulfillmentsClient.GetFulfillmentAsync(name); // End snippet }
/// <summary>Snippet for GetFulfillmentAsync</summary> public async Task GetFulfillmentAsync() { // Snippet: GetFulfillmentAsync(string, CallSettings) // Additional: GetFulfillmentAsync(string, CancellationToken) // Create client FulfillmentsClient fulfillmentsClient = await FulfillmentsClient.CreateAsync(); // Initialize request argument(s) string name = "projects/[PROJECT]/agent/fulfillment"; // Make the request Fulfillment response = await fulfillmentsClient.GetFulfillmentAsync(name); // End snippet }
/// <summary>Snippet for GetFulfillment</summary> public void GetFulfillmentRequestObject() { // Snippet: GetFulfillment(GetFulfillmentRequest, CallSettings) // Create client FulfillmentsClient fulfillmentsClient = FulfillmentsClient.Create(); // Initialize request argument(s) GetFulfillmentRequest request = new GetFulfillmentRequest { FulfillmentName = FulfillmentName.FromProject("[PROJECT]"), }; // Make the request Fulfillment response = fulfillmentsClient.GetFulfillment(request); // End snippet }
public async Task <IActionResult> ChangeFulfillmentNote(AdminChangeFulfillmentNoteViewModel model) { Fulfillment fulfillment = await _context.Fulfillments.Include(u => u.ApplicationUser).SingleAsync(f => f.ID == model.FulfillmentID); if (fulfillment == null) { throw new ApplicationException($"AAAAAAAAAAAHHHHHHHHHHHHHH!"); } fulfillment.Note = model.Note; _context.SaveChanges(); return(RedirectToAction(nameof(Fulfillments))); }
private void UpsertOrderFulfillment(ShopifyOrder orderRecord, Fulfillment fulfillment) { var fulfillmentRecord = orderRecord .ShopifyFulfillments .FirstOrDefault(x => x.ShopifyFulfillmentId == fulfillment.id); if (fulfillmentRecord != null) { // Existing Fulfillment Record // fulfillmentRecord.ShopifyStatus = fulfillment.status; fulfillmentRecord.LastUpdated = DateTime.UtcNow; _orderRepository.SaveChanges(); return; } var matchedRecord = orderRecord .ShopifyFulfillments .FirstOrDefault(x => x.ShopifyTrackingNumber == fulfillment.tracking_number); if (matchedRecord != null) { // Matched via Tracking Number in Shopify // _executionLogService.Log( LogBuilder.FillingUnknownShopifyFulfillmentRefByTracking(matchedRecord)); matchedRecord.ShopifyFulfillmentId = fulfillment.id; matchedRecord.LastUpdated = DateTime.UtcNow; _orderRepository.SaveChanges(); } else { // Creating new Fulfillment Record // var newRecord = new ShopifyFulfillment(); newRecord.ShopifyOrderMonsterId = orderRecord.MonsterId; newRecord.ShopifyFulfillmentId = fulfillment.id; newRecord.ShopifyOrderId = orderRecord.ShopifyOrderId; newRecord.ShopifyStatus = fulfillment.status; newRecord.DateCreated = DateTime.UtcNow; newRecord.LastUpdated = DateTime.UtcNow; _orderRepository.InsertFulfillment(newRecord); } }
public async Task <IActionResult> RetrievingFulfillment([FromBody] FulfillmentDetailModel model) { Fulfillment response = new Fulfillment(); try { var service = new FulfillmentService(model.shopifyurl, model.token); response = await service.GetAsync(model.orderId, model.fulfillmentId); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok(response)); }
/// <summary>Snippet for UpdateFulfillmentAsync</summary> public async Task UpdateFulfillmentAsync() { // Snippet: UpdateFulfillmentAsync(Fulfillment, FieldMask, CallSettings) // Additional: UpdateFulfillmentAsync(Fulfillment, FieldMask, CancellationToken) // Create client FulfillmentsClient fulfillmentsClient = await FulfillmentsClient.CreateAsync(); // Initialize request argument(s) Fulfillment fulfillment = new Fulfillment(); FieldMask updateMask = new FieldMask(); // Make the request Fulfillment response = await fulfillmentsClient.UpdateFulfillmentAsync(fulfillment, updateMask); // End snippet }
public async Task ThrowIfUsernameIsNullOrWhitespace() { var context = Helpers.GetMockContext(); var stateManager = new MockReliableStateManager(); var service = new Fulfillment(context, stateManager); var username = "******"; var request = new UserRequestModel { CurrencyAmounts = null, Username = username, }; await Assert.ThrowsAsync <InvalidUserRequestException>(() => service.AddUserAsync(request, CancellationToken.None)); }
/// <summary>Snippet for UpdateFulfillment</summary> public void UpdateFulfillmentRequestObject() { // Snippet: UpdateFulfillment(UpdateFulfillmentRequest, CallSettings) // Create client FulfillmentsClient fulfillmentsClient = FulfillmentsClient.Create(); // Initialize request argument(s) UpdateFulfillmentRequest request = new UpdateFulfillmentRequest { Fulfillment = new Fulfillment(), UpdateMask = new FieldMask(), }; // Make the request Fulfillment response = fulfillmentsClient.UpdateFulfillment(request); // End snippet }
public async Task ThrowIfAskQuantityIsLowerThanBidQuantity() { var context = Helpers.GetMockContext(); var stateManager = new MockReliableStateManager(); var service = new Fulfillment(context, stateManager); var ask = new Order("user1", CurrencyPair.GBPUSD, 5, 10); var bid = new Order("user2", CurrencyPair.GBPUSD, 100, 10); var request = new TradeRequestModel { Ask = ask, Bid = bid, }; await Assert.ThrowsAsync <InvalidTradeRequestException>(() => service.AddTradeAsync(request)); }
public async Task <Fulfillment> CreateFulfillment(long orderId, bool multipleTrackingNumbers = false, IEnumerable <LineItem> items = null) { Fulfillment fulfillment = new Fulfillment() { TrackingCompany = "Jack Black's Pack, Stack and Track", TrackingUrl = "https://example.com/123456789", TrackingNumber = "123456789", LineItems = CreatedOrders.First().LineItems }; fulfillment = await FulfillmentService.CreateAsync(orderId, fulfillment, false); CreatedFulfillments.Add(fulfillment); return(fulfillment); }
public async Task <Fulfillment> CreateFulfillment(long orderId, bool multipleTrackingNumbers = false, IEnumerable <LineItem> items = null) { Fulfillment fulfillment; if (multipleTrackingNumbers) { fulfillment = new Fulfillment() { TrackingCompany = "Jack Black's Pack, Stack and Track", TrackingUrls = new string[] { "https://example.com/da10038ee679f9afc93a785cafdd8d52", "https://example.com/6349a40313ae3c7544331ff9fb44f28c", "https://example.com/ca0b2d7bcccec4b58a94a24fa04101d3" }, TrackingNumbers = new string[] { "da10038ee679f9afc93a785cafdd8d52", "6349a40313ae3c7544331ff9fb44f28c", "ca0b2d7bcccec4b58a94a24fa04101d3" } }; } else { fulfillment = new Fulfillment() { TrackingCompany = "Jack Black's Pack, Stack and Track", TrackingUrl = "https://example.com/123456789", TrackingNumber = "123456789", }; } if (items != null) { fulfillment.LineItems = items; } fulfillment.NotifyCustomer = false; fulfillment.LocationId = LocationId; fulfillment = await FulfillmentService.CreateAsync(orderId, fulfillment); CreatedFulfillments.Add(fulfillment); return(fulfillment); }