private void ShouldItBeMarkedDistributed() { if (_packedContainers.Count == 0) { Status = Distributed; } }
public async Task UpdateStatus(int id, ShipmentStatus status) { Shipment shipment = await _context.Shipments.FindAsync(id); shipment.Status = status; await _context.SaveChangesAsync(); }
/// <summary> /// Gets (creates a new <see cref="IShipment"/>) from values saved in the <see cref="ExtendedDataCollection"/> /// </summary> /// <typeparam name="T"> /// The type of line item /// </typeparam> /// <param name="extendedData"> /// The extended Data. /// </param> /// <returns> /// The <see cref="IShipment"/>. /// </returns> public static IShipment GetShipment<T>(this ExtendedDataCollection extendedData) where T : LineItemBase { var origin = extendedData.GetAddress(Constants.ExtendedDataKeys.ShippingOriginAddress); var destination = extendedData.GetAddress(Constants.ExtendedDataKeys.ShippingDestinationAddress); var lineItemCollection = extendedData.GetLineItemCollection<T>(); if (origin == null) throw new NullReferenceException("ExtendedDataCollection does not contain an 'origin shipping address'"); if (destination == null) throw new NullReferenceException("ExtendedDataCollection does not container a 'destination shipping address'"); if (lineItemCollection == null) throw new NullReferenceException("ExtendedDataCollection does not contain a 'line item collection'"); // TODO - this is a total hack since this value can be changed in the database var quoted = new ShipmentStatus() { Key = Constants.DefaultKeys.ShipmentStatus.Quoted, Alias = "quoted", Name = "Quoted", Active = true, CreateDate = DateTime.Now, UpdateDate = DateTime.Now }; return new Shipment(quoted, origin, destination, lineItemCollection) { ShipMethodKey = extendedData.ContainsKey(Constants.ExtendedDataKeys.ShipMethodKey) ? extendedData.GetShipMethodKey() : Guid.Empty }; }
public ShipmentStatus TrackShipment(string trackingNumber, CarrierAccount carrierAccount) { ShipmentStatus shipmentStatus = null; try { dynamic dataObject = new ExpandoObject(); dynamic track = new ExpandoObject(); track.shipping_account = carrierAccount.id; track.carrier = carrierAccount.carrier; track.tracking_number = trackingNumber; track.test = Test; dataObject.track = track; string payload = JsonConvert.SerializeObject(dataObject); string jsonResponse = DataLayer.getResponseFromApi(ApiKey, DataLayer.WebMethod.POST, "/track", payload); ZkSuccess zkSuccess = GetApiCallSuccess(jsonResponse); if (zkSuccess.success == true) { shipmentStatus = JsonConvert.DeserializeObject <ShipmentStatus>(jsonResponse); } else { throw new Exception(zkSuccess.error_message + " " + zkSuccess.detail); } } catch (Exception ex) { throw new Exception(ex.Message); } return(shipmentStatus); }
public ActionResult DeleteConfirmed(int id) { ShipmentStatus shipmentStatus = db.ShipmentStatuses.Find(id); db.ShipmentStatuses.Remove(shipmentStatus); db.SaveChanges(); return(RedirectToAction("Index")); }
private bool IsShipmentStateInsertable(Guid shipmentKey, ShipmentStatus status) { var shipmentStates = GetShipmentStates(shipmentKey); var latestState = (from state in shipmentStates orderby state.ShipmentStatus descending select state).First(); return(status > latestState.ShipmentStatus); }
public ActionResult Edit([Bind(Include = "Id,Name")] ShipmentStatus shipmentStatus) { if (ModelState.IsValid) { db.Entry(shipmentStatus).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(shipmentStatus)); }
public void Send() { if (Status != ShipmentStatus.Pending) { throw new StreetwoodException(ErrorCode.CannotSendNotPendingShipment); } Status = ShipmentStatus.InProgress; UpdatedAt = DateTimeOffset.UtcNow; }
public void Complete() { if (Status != ShipmentStatus.InProgress) { throw new StreetwoodException(ErrorCode.CannotCompleteNotInProgressShipment); } Status = ShipmentStatus.Completed; UpdatedAt = DateTimeOffset.UtcNow; }
public ActionResult Create([Bind(Include = "Id,Name")] ShipmentStatus shipmentStatus) { if (ModelState.IsValid) { db.ShipmentStatuses.Add(shipmentStatus); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(shipmentStatus)); }
private static ShipmentState InsertShipmentState(Guid ShipmentKey, ShipmentStatus status) { var shipmentState = new ShipmentState { Key = Guid.NewGuid(), ShipmentKey = ShipmentKey, ShipmentStatus = status, CreatedOn = DateTime.Now }; return(shipmentState); }
public Shipment(string trackingId, string company, DateTime estimatedArrivalDate, decimal shippingCost, string destinationAddress, string comments) { TrackingId = trackingId ?? throw new ArgumentNullException(nameof(trackingId)); Company = company ?? throw new ArgumentNullException(nameof(company)); EstimatedArrivalDate = estimatedArrivalDate; ShippingCost = shippingCost; DestinationAddress = destinationAddress; Comments = comments; Status = new ShipmentStatus(); }
public void TrackShipmentTest() { string trackingNumber = "122816215025810"; CarrierAccount fedexCarrierAccount = new CarrierAccount(); fedexCarrierAccount.id = fedexShippingAccountId; fedexCarrierAccount.carrier = "fedex"; zkService.Test = true; ShipmentStatus shipmentStatus = zkService.TrackShipment(trackingNumber, fedexCarrierAccount); Assert.IsTrue(shipmentStatus != null); }
private ShipmentState InsertShipmentState(Guid ShipmentKey, ShipmentStatus status) { var shipmentState = new ShipmentState { Key = Guid.NewGuid(), ShipmentKey = ShipmentKey, ShipmentStatus = status, CreatedOn = DateTime.Now }; _shipmentStateRepository.Add(shipmentState); _shipmentStateRepository.Save(); return(shipmentState); }
// GET: ADMIN/ShipmentStatus/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ShipmentStatus shipmentStatus = db.ShipmentStatuses.Find(id); if (shipmentStatus == null) { return(HttpNotFound()); } return(View(shipmentStatus)); }
public OperationResult <ShipmentState> AddShipmentState(Guid shipmentKey, ShipmentStatus status) { if (!IsShipmentStateInsertable(shipmentKey, status)) { return(new OperationResult <ShipmentState>(false)); } var shipmentState = InsertShipmentState(shipmentKey, status); return(new OperationResult <ShipmentState>(true) { Entity = shipmentState }); }
public ShipmentResult( bool isStoppedInCustom, ShipmentStatus status, DateTime receivedDate, CheckPointResult checkPointResult, DateTime createdAt, DateTime?updatedAt) { IsStoppedInCustoms = isStoppedInCustom; Status = status; ReceivedDate = receivedDate; CheckPointResult = checkPointResult; CreatedAt = createdAt; UpdatedAt = updatedAt; }
/// <summary> /// Builds a shipment status entity. /// </summary> /// <param name="dto"> /// The dto. /// </param> /// <returns> /// The <see cref="IShipmentStatus"/>. /// </returns> public IShipmentStatus BuildEntity(ShipmentStatusDto dto) { var shipmentStatus = new ShipmentStatus() { Key = dto.Key, Name = dto.Name, Alias = dto.Alias, Reportable = dto.Reportable, Active = dto.Active, SortOrder = dto.SortOrder, UpdateDate = dto.UpdateDate, CreateDate = dto.CreateDate }; shipmentStatus.ResetDirtyProperties(); return(shipmentStatus); }
public Shipment( Guid shipmentId, Guid?packageId, bool isStoppedInCustom, ShipmentStatus status, DateTime receivedDate, CheckPoint checkPoint, DateTime createdAt, DateTime?updatedAt) { ShipmentId = shipmentId; PackageId = packageId; IsStoppedInCustoms = isStoppedInCustom; Status = status; ReceivedDate = receivedDate; CheckPoint = checkPoint; CreatedAt = createdAt; UpdatedAt = updatedAt; }
public List <string> ListShipmentsByStatus(ShipmentStatus shipmentStatus) { using (var client = CreateHttpClient()) { var postObj = new { shipmentStatus = shipmentStatus }; var response = client.SyncPostJson("/json/ShipmentService/ListByStatus", postObj); string str = response.Content.ReadAsStringAsync().Result; JsonResponse <List <string> > res = JsonConvert.DeserializeObject <JsonResponse <List <string> > >(str); CheckResponse(res); return(res.ResponseData); } }
/// <summary> /// CreateShipmentStatus /// </summary> /// <param name="code"></param> /// <param name="iconName"></param> /// <param name="dictionary"></param> /// <param name="transaction"></param> /// <returns></returns> private static async Task <int> CreateShipmentStatus(string code, string iconName, Dictionary dictionary, IDbTransaction transaction = null) { var item = _unitOfWork.ShipmentStatusRepository.Get("Code='" + code + "'"); if (item == null) { var dictionaryId = await _unitOfWork.DictionaryRepository.AddAsync(dictionary, transaction, true, false); item = new ShipmentStatus { DateCreated = DateTime.Now, DateModified = DateTime.Now, UserIdCreated = 1000, Code = code, DictionaryId = dictionaryId }; return(await _unitOfWork.ShipmentStatusRepository.AddAsync(item)); } if (!item.DictionaryId.HasValue) { item.DictionaryId = await _unitOfWork.DictionaryRepository.AddAsync(dictionary, transaction, true, false); } if (item.DictionaryId == null) { return(item.Id); } var currentDictionary = await _unitOfWork.DictionaryRepository.GetAsync(item.DictionaryId.Value); dictionary.Id = currentDictionary.Id; dictionary.DateModified = DateTime.Now; await _unitOfWork.DictionaryRepository.UpdateAsync(dictionary, transaction, true, null, false); item.DictionaryId = dictionary.Id; await _unitOfWork.ShipmentStatusRepository.UpdateAsync(item, transaction); return(item.Id); }
public Shipment CreateShipmentFromOrder(int orderID, ShipmentStatus shipmentStatus = ShipmentStatus.Pending) { using (var client = CreateHttpClient()) { var postObj = new { orderID = orderID, shipmentStatus = shipmentStatus }; var response = client.SyncPostJson("/json/ShipmentService/CreateFromOrder", postObj); string str = response.Content.ReadAsStringAsync().Result; JsonResponse <Shipment> res = JsonConvert.DeserializeObject <JsonResponse <Shipment> >(str); CheckResponse(res); return(res.ResponseData); } }
public bool UpdateShippingStatus(long shippingDetailId, ShipmentStatus status, long modifiedByOrgRoleUserId) { var shippingDetail = _shippingDetailRepository.GetById(shippingDetailId); shippingDetail.Status = status; shippingDetail.DataRecorderMetaData.DateModified = DateTime.Now; shippingDetail.DataRecorderMetaData.DataRecorderModifier = new OrganizationRoleUser(modifiedByOrgRoleUserId); if (status == ShipmentStatus.Shipped) { shippingDetail.ShippedByOrgRoleUserId = modifiedByOrgRoleUserId; } shippingDetail = _shippingDetailRepository.Save(shippingDetail); if (shippingDetail.Id > 0) { return(true); } return(false); }
/// <inheritdoc/> public string ToDelimitedString() { CultureInfo culture = CultureInfo.CurrentCulture; return(string.Format( culture, StringHelper.StringFormatSequence(0, 12, Configuration.FieldSeparator), Id, ShipmentId?.ToDelimitedString(), InternalShipmentId != null ? string.Join(Configuration.FieldRepeatSeparator, InternalShipmentId.Select(x => x.ToDelimitedString())) : null, ShipmentStatus?.ToDelimitedString(), ShipmentStatusDateTime.HasValue ? ShipmentStatusDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, ShipmentStatusReason?.ToDelimitedString(), ShipmentPriority?.ToDelimitedString(), ShipmentConfidentiality != null ? string.Join(Configuration.FieldRepeatSeparator, ShipmentConfidentiality.Select(x => x.ToDelimitedString())) : null, NumberOfPackagesInShipment.HasValue ? NumberOfPackagesInShipment.Value.ToString(Consts.NumericFormat, culture) : null, ShipmentCondition != null ? string.Join(Configuration.FieldRepeatSeparator, ShipmentCondition.Select(x => x.ToDelimitedString())) : null, ShipmentHandlingCode != null ? string.Join(Configuration.FieldRepeatSeparator, ShipmentHandlingCode.Select(x => x.ToDelimitedString())) : null, ShipmentRiskCode != null ? string.Join(Configuration.FieldRepeatSeparator, ShipmentRiskCode.Select(x => x.ToDelimitedString())) : null ).TrimEnd(Configuration.FieldSeparator.ToCharArray())); }
public async Task <GetPagedResult <Package> > GetPackagesByStatusCode( ShipmentStatus statusCode, int page, int pageSize) { var packages = _dbcontext .Packages .AsNoTracking() .Include(p => p.Shipment) .ThenInclude(s => s.CheckPoint) .Where(p => p.Shipment.Status == statusCode) .Skip(page * pageSize) .Take(pageSize); var totalCount = await _dbcontext .Packages .CountAsync(p => p.Shipment.Status == statusCode); return(new GetPagedResult <Package>( list: packages.Select(p => p.ToDomain()), totalCount: totalCount)); }
// // GET: /Quote/ public ActionResult Index(string agentname, string country, string refNumber, string carrier, string mode, ShipmentStatus? status, DateTime? fromDate, DateTime? toDate, string sort, string sortDir, int page = 1, int pageSize = 15) { IQueryable<Shipment> shipments = _uow.ShipmentRepository.Get(); if (!string.IsNullOrWhiteSpace(agentname)) { shipments = shipments.Where(x => x.Title.Contains(agentname)); } if (mode != null) { shipments = shipments.Where(x => x.TransportMode.Code == mode.ToString()); } if (status != null) { /* Draft Sent Cancelled Expired Interested Declined New * */ if (status == ShipmentStatus.Active) { shipments = shipments.Where(x => new string[] { "Interested", "New", "Sent" }.Contains(x.Status.Code)); } else if (status == ShipmentStatus.Expired) { shipments = shipments.Where(x => new string[] { "Cancelled", "Expired", "Declined" }.Contains(x.Status.Code)); } } //shipments.Where(x => x.RFQs.Any(y => y.Status.Code == "")); shipments = shipments.OrderByDescending(x => x.UpdatedOn); IPagedList<Shipment> data = shipments.ToPagedList(page, pageSize); return View(data); }
private bool IsShipmentStateInsertable(Guid shipmentKey, ShipmentStatus status) { var shipmentStates = GetShipmentStates(shipmentKey); var latestState = (from state in shipmentStates orderby state.ShipmentStatus descending select state).First(); return status > latestState.ShipmentStatus; }
private ShipmentState InsertShipmentState(Guid ShipmentKey, ShipmentStatus status) { var shipmentState = new ShipmentState { Key = Guid.NewGuid(), ShipmentKey = ShipmentKey, ShipmentStatus = status, CreatedOn = DateTime.Now }; _shipmentStateRepository.Add(shipmentState); _shipmentStateRepository.Save(); return shipmentState; }
public OperationResult<ShipmentState> AddShipmentState(Guid shipmentKey, ShipmentStatus status) { if (!IsShipmentStateInsertable(shipmentKey, status)) { return new OperationResult<ShipmentState>(false); } var shipmentState = InsertShipmentState(shipmentKey, status); return new OperationResult<ShipmentState>(true) { Entity = shipmentState }; }
public async Task <List <T> > GetList <T>(ShipmentStatus status) { return(await _mapper.ProjectTo <T>(_context.Shipments.Details().Where(x => x.Status == status)).ToListAsync()); }
private static ShipmentState InsertShipmentState(Guid ShipmentKey, ShipmentStatus status) { var shipmentState = new ShipmentState { Key = Guid.NewGuid(), ShipmentKey = ShipmentKey, ShipmentStatus = status, CreatedOn = DateTime.Now }; return shipmentState; }
public OperationResult <ShipmentState> AddShipmentState(Guid shipmentKey, ShipmentStatus status) { throw new NotImplementedException(); }
protected PickedInventory CreatePickedInventory(IPickedInventoryKey pickedInventoryKey, MovementOrderDTO order, ShipmentStatus shipmentStatus) { LoadCount.AddRead(EntityTypes.PickedInventory); int? employeeId = null; DateTime? timestamp = null; var latestMoveDetail = order.tblMoveDetails.OrderByDescending(d => d.MDetail).FirstOrDefault(); if(latestMoveDetail != null) { employeeId = latestMoveDetail.EmployeeID; timestamp = latestMoveDetail.MDetail.ConvertLocalToUTC(); } if(employeeId == null) { employeeId = employeeId ?? order.EmployeeID; timestamp = timestamp ?? order.EntryDate.ConvertLocalToUTC(); if(employeeId == null || timestamp == null) { var latestOutgoing = order.tblOutgoings.OrderByDescending(d => d.EntryDate).FirstOrDefault(); if(latestOutgoing != null) { employeeId = employeeId ?? latestOutgoing.EmployeeID; timestamp = timestamp ?? latestOutgoing.EntryDate.ConvertLocalToUTC(); } } } if(timestamp == null) { Log(new CallbackParameters(CallbackReason.PickedInventoryNoTimestamp) { MovementOrder = order }); return null; } employeeId = employeeId ?? NewContextHelper.DefaultEmployee.EmployeeId; if(employeeId == NewContextHelper.DefaultEmployee.EmployeeId) { Log(new CallbackParameters(CallbackReason.PickedInventoryDefaultEmployee) { MovementOrder = order, DefaultEmployeeId = employeeId.Value }); } return new PickedInventory { EmployeeId = employeeId.Value, TimeStamp = timestamp.Value, DateCreated = pickedInventoryKey.PickedInventoryKey_DateCreated, Sequence = pickedInventoryKey.PickedInventoryKey_Sequence, PickedReason = ((TransType)order.TTypeID).ToPickedReason(), Archived = order.Status > (int)tblOrderStatus.Staged, Items = CreatePickedInventoryItemsFromMoveDetails(pickedInventoryKey, order, shipmentStatus).ToList() }; }
public void Always_DefaultsStatusToOpen() { var status = new ShipmentStatus(); Assert.That(status.CurrentState, Is.EqualTo(ShipmentStatus.State.Open)); }
/// <summary> /// Set status of shipment /// </summary> /// <param name="shipmentId">Shipment ID</param> /// <param name="status">Shipment Status</param> public void SetShipmentStatus(int shipmentId, ShipmentStatus status) { var client = GetRestClient(); var request = new RestRequest { Resource = "api/shipment/status/" + shipmentId, RequestFormat = DataFormat.Json, Method = Method.PUT }; request.AddParameter("status", EnumUtils.stringValueOf(status)); var response = client.Execute(request); if (response.ErrorException != null) throw new ApplicationException("Error updating status of Shipment", response.ErrorException); }
private static bool IsShipmentStateInsertable(IEnumerable<ShipmentState> shipmentStates, Guid shipmentKey, ShipmentStatus status) { var latestState = (from state in shipmentStates orderby state.ShipmentStatus descending select state).First(); return status > latestState.ShipmentStatus; }
private IEnumerable<PickedInventoryItem> CreatePickedInventoryItemsFromMoveDetails(IPickedInventoryKey pickedInventoryKey, MovementOrderDTO order, ShipmentStatus shipmentStatus) { var sequence = 0; var moveDetails = order.tblMoveDetails.ToList(); foreach(var moveDetail in moveDetails) { LoadCount.AddRead(EntityTypes.PickedInventoryItem); var lotKey = LotNumberParser.ParseLotNumber(moveDetail.Lot); if(lotKey == null) { Log(new CallbackParameters(CallbackReason.MoveDetailInvalidLotNumber) { MoveDetail = moveDetail }); continue; } if(!NewContextHelper.LotLoaded(lotKey)) { Log(new CallbackParameters(CallbackReason.MoveDetailLotNotLoaded) { MoveDetail = moveDetail }); continue; } var packaging = moveDetail.PType == (int?)LotTypeEnum.Packaging ? NewContextHelper.NoPackagingProduct : NewContextHelper.GetPackagingProduct(moveDetail.PkgID); if(packaging == null) { Log(new CallbackParameters(CallbackReason.MoveDetailPackagingNotLoaded) { MoveDetail = moveDetail }); continue; } var pickedLocation = NewContextHelper.GetLocation(moveDetail.LocID); if(pickedLocation == null) { pickedLocation = NewContextHelper.UnknownFacilityLocation; if(pickedLocation == null) { Log(new CallbackParameters(CallbackReason.MoveDetailUnknownWarehouseLocationNotLoaded) { MoveDetail = moveDetail }); continue; } Log(new CallbackParameters(CallbackReason.MoveDetailDefaultUnknownWarehouseLocation) { MoveDetail = moveDetail, Location = pickedLocation }); } var currentLocation = shipmentStatus == ShipmentStatus.Shipped ? NewContextHelper.GetLocation(moveDetail.Move2) ?? pickedLocation : pickedLocation; var treatment = NewContextHelper.GetInventoryTreatment(moveDetail.TrtmtID); if(treatment == null) { Log(new CallbackParameters(CallbackReason.MoveDetailTreatmentNotLoaded) { MoveDetail = moveDetail }); continue; } const string tote = ""; yield return new PickedInventoryItem { DateCreated = pickedInventoryKey.PickedInventoryKey_DateCreated, Sequence = pickedInventoryKey.PickedInventoryKey_Sequence, ItemSequence = ++sequence, DetailID = moveDetail.MDetail, LotDateCreated = lotKey.LotKey_DateCreated, LotDateSequence = lotKey.LotKey_DateSequence, LotTypeId = lotKey.LotKey_LotTypeId, PackagingProductId = packaging.Id, TreatmentId = treatment.Id, ToteKey = tote, Quantity = (int)moveDetail.Quantity, FromLocationId = pickedLocation.Id, CurrentLocationId = currentLocation.Id, CustomerLotCode = moveDetail.CustLot, CustomerProductCode = moveDetail.CustProductCode }; } }