public async Task Test_Get_TrackingNo_Range() { var trackingApiService = new TrackerApiService(true); var response = await trackingApiService.GetTrackingNoRange(new GetTrackingNoRangeRequest() { Type = "1", CustomerCode = "T001" }); Assert.IsTrue(!response.Result.Equals(null)); }
public async Task <Dal.Entities.Delivery> MarkAsProcessing(long id, int requiredTrackingNumberCount) { var delivery = await GetDeliveryById(id); if (!CanMarkAsProcessing(delivery)) { throw new ServiceException(new ErrorMessage[] { new ErrorMessage() { Message = "Unable to mark as processing" } }); } var supplier = await _supplierService.GetSupplierById(delivery.SupplierId); var trackingNumbers = new List <string>(); for (int i = 0; i < requiredTrackingNumberCount; i++) { var trackingNumberResponse = await _trackerApiService.GetTrackingNoRange(new GetTrackingNoRangeRequest() { CustomerCode = supplier.TrackerCode, Type = delivery.Type == DeliveryType.Cod ? "1" : "2" }); if (trackingNumberResponse.IsSuccess != "1") { throw new ServiceException(new ErrorMessage[] { new ErrorMessage() { Message = "Unable to get the tracking number" } }); } trackingNumbers.Add(trackingNumberResponse.Result.TrackingNumber); } delivery.DeliveryTrackings = new List <DeliveryTracking>(); foreach (var trackingNumber in trackingNumbers) { delivery.DeliveryTrackings.Add(new DeliveryTracking() { Status = TrackingStatus.Pending, TrackingNumber = trackingNumber, DeliveryTrackingItems = delivery.DeliveryItems.Select(item => new DeliveryTrackingItem() { ProductId = item.ProductId, Quantity = 0, UnitCost = item.UnitCost }).ToList() }); } delivery.DeliveryStatus = DeliveryStatus.Processing; await _unitOfWork.SaveChanges(); await AddDeliveryNote(delivery.Id, "Mark as processing"); return(delivery); }