public async Task <ShipmentDetailView> MapToDetailView(ShipmentDetail inputObject) { ShipmentDetailView outObject = mapper.Map <ShipmentDetailView>(inputObject); await Task.Yield(); return(outObject); }
public void UploadTracking(StreamReader trackingStreamReader) { try { var dszTrackings = _csvContext.Read <DSZTrackingFile>(trackingStreamReader, _csvFileDesc); //check file //if(dszTrackings.Any(t=>!Regex.IsMatch( t.NetoOrderID,""))) foreach (var tracking in dszTrackings) { if (!Regex.IsMatch(tracking.NetoOrderLineID, @"^N\d+-\d{1}$")) { throw new Exception($"Neto Order Line ID {tracking.NetoOrderLineID} is not matching with the pattern Nxxxx-x"); } } var NetoOrderLineIDs = dszTrackings.Select(t => t.NetoOrderLineID.Trim()); var orderLines = _orderLineRepository.Table.Where(line => NetoOrderLineIDs.Contains(line.Ref1)).ToList(); var linesNotInDB = NetoOrderLineIDs.Where(id => !orderLines.Select(line => line.Ref1).Contains(id)).ToList(); if (linesNotInDB.Count > 0) { throw new Exception($"Neto Order Line ID {linesNotInDB.Aggregate((current, next) => current + "," + next)} do not in database."); } var linesNoteBay = orderLines.Where(line => string.IsNullOrWhiteSpace(line.Ref2)).ToList(); if (linesNoteBay.Count > 0) { throw new Exception($"Neto Order Line ID {linesNoteBay.Select(line => line.Ref1).Aggregate((current, next) => current + "," + next)} are not from eBay."); } var orderLineTrackings = from tracking in dszTrackings join orderLine in orderLines on tracking.NetoOrderLineID.Trim().ToUpper() equals orderLine.Ref1.ToUpper() //select new { tracking.NetoOrderLineID, tracking.Carrier, tracking.TrackingNumber, eBayOrderLineItemID = orderLine.Ref2, OrderLineID = orderLine.ID }; select new { TrackingDetail = tracking, OrderLine = orderLine }; var shipmentDetails = new List <ShipmentDetail>(); foreach (var orderLineTracking in orderLineTrackings) { var shipmentDetail = new ShipmentDetail(); shipmentDetail.OrderLineItemID = orderLineTracking.OrderLine.Ref2; shipmentDetail.ShippingCarrierUsed = MapShippingCarrier(orderLineTracking.TrackingDetail.Carrier); shipmentDetail.ShipmentTrackingNumber = orderLineTracking.TrackingDetail.TrackingNumber; shipmentDetails.Add(shipmentDetail); var orderLine = orderLineTracking.OrderLine; orderLine.Ref3 += (string.IsNullOrEmpty(orderLine.Ref3) ? string.Empty : ";") + shipmentDetail.ShippingCarrierUsed; orderLine.Ref4 += (string.IsNullOrEmpty(orderLine.Ref4) ? string.Empty : ";") + shipmentDetail.ShipmentTrackingNumber; } _eBayAPICallManager.UpdateeBayShipment(shipmentDetails); _orderLineRepository.Update(orderLineTrackings.Select(lt => lt.OrderLine), l => l.Ref3, l => l.Ref4); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ShipmentDetailEntity Update(EmployeeEntity EmployeeEntity, Guid ShipmentDetailId, ShipmentDetailEntity ShipmentDetailEntity) { ShipmentDetailEntity.Id = ShipmentDetailId; ShipmentDetail ShipmentDetail = new ShipmentDetail(ShipmentDetailEntity); UnitOfWork.ShipmentDetailRepository.AddOrUpdate(ShipmentDetail); UnitOfWork.Complete(); return(Get(EmployeeEntity, ShipmentDetail.Id)); }
public ShipmentDetailEntity Create(EmployeeEntity EmployeeEntity, ShipmentDetailEntity ShipmentDetailEntity) { if (ShipmentDetailEntity == null) { throw new NotFoundException(); } ShipmentDetail ShipmentDetail = new ShipmentDetail(ShipmentDetailEntity); UnitOfWork.ShipmentDetailRepository.AddOrUpdate(ShipmentDetail); UnitOfWork.Complete(); return(Get(EmployeeEntity, ShipmentDetail.Id)); }
public OperationsStatus InsertShipmentDetail(ShipmentDetail shipmentDetailObj) { OperationsStatus operationsStatusObj = new OperationsStatus(); try { SqlParameter statusCode = null; using (SqlConnection con = _databaseFactory.GetDBConnection()) { using (SqlCommand cmd = new SqlCommand()) { if (con.State == ConnectionState.Closed) { con.Open(); } cmd.Connection = con; cmd.CommandText = "[InsertShipmentDetail]"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ShipmentID", SqlDbType.Int).Value = shipmentDetailObj.ShipmentID; cmd.Parameters.Add("@OrderItemID", SqlDbType.Int).Value = shipmentDetailObj.OrderItemID; cmd.Parameters.Add("@ShippedQty", SqlDbType.Int).Value = shipmentDetailObj.ShippedQty; cmd.Parameters.Add("@CreatedBy", SqlDbType.NVarChar, 250).Value = shipmentDetailObj.log.CreatedBy; cmd.Parameters.Add("@CreatedDate", SqlDbType.DateTime).Value = shipmentDetailObj.log.CreatedDate; statusCode = cmd.Parameters.Add("@Status", SqlDbType.SmallInt); statusCode.Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); switch (statusCode.Value.ToString()) { case "0": operationsStatusObj.StatusCode = Int16.Parse(statusCode.Value.ToString()); operationsStatusObj.StatusMessage = constObj.InsertFailure; break; case "1": operationsStatusObj.StatusCode = Int16.Parse(statusCode.Value.ToString()); operationsStatusObj.StatusMessage = constObj.InsertSuccess; break; default: break; } } } } catch (Exception ex) { throw ex; } return(operationsStatusObj); }
public ShipmentDetail GetShipmentDetail(int shipmentid) { ShipmentDetail shipmentDetail = new ShipmentDetail(); shipmentDetail.Shipment = GetShipment(shipmentid); shipmentDetail.ShipmentLines = ShipmentDAL.GetShipmentLineByShipmentID(shipmentid); shipmentDetail.ShipmentPackages = ShipmentDAL.GetShipmentPackageByShipmentID(shipmentid); shipmentDetail.ShipmentFees = ShipmentDAL.GetShipmentFeeByShipmentID(shipmentid); shipmentDetail.ShipmentContacts = ShipmentDAL.GetShipmentContactByShipmentID(shipmentid); shipmentDetail.ShipmentComments = ShipmentDAL.GetShipmentCommentByShipmentID(shipmentid); return(shipmentDetail); }
public List <ShipmentDetail> GetAllShipmentDetail(int ID) { List <ShipmentDetail> ShipmentDetailList = null; try { using (SqlConnection con = _databaseFactory.GetDBConnection()) { using (SqlCommand cmd = new SqlCommand()) { if (con.State == ConnectionState.Closed) { con.Open(); } cmd.Connection = con; cmd.CommandText = "[GetAllShipmentDetails]"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ID", SqlDbType.Int).Value = ID; using (SqlDataReader sdr = cmd.ExecuteReader()) { if ((sdr != null) && (sdr.HasRows)) { ShipmentDetailList = new List <ShipmentDetail>(); while (sdr.Read()) { ShipmentDetail _shipmentDetailObj = new ShipmentDetail(); { _shipmentDetailObj.ID = (sdr["ID"].ToString() != "" ? int.Parse(sdr["ID"].ToString()) : _shipmentDetailObj.ID); _shipmentDetailObj.ShipmentID = (sdr["ShipmentID"].ToString() != "" ? int.Parse(sdr["ShipmentID"].ToString()) : _shipmentDetailObj.ShipmentID); _shipmentDetailObj.OrderItemID = (sdr["OrderItemID"].ToString() != "" ? int.Parse(sdr["OrderItemID"].ToString()) : _shipmentDetailObj.ShipmentID); _shipmentDetailObj.ShippedQty = (sdr["ShippedQty"].ToString() != "" ? int.Parse(sdr["ShippedQty"].ToString()) : _shipmentDetailObj.ShippedQty); _shipmentDetailObj.OrderDetailObj = new OrderDetail(); _shipmentDetailObj.OrderDetailObj.ProductSpecXML = sdr["Name"].ToString() + "||" + sdr["ProductSpecXML"].ToString(); _shipmentDetailObj.OrderDetailObj.Qty = (sdr["Qty"].ToString() != "" ? int.Parse(sdr["Qty"].ToString()) : _shipmentDetailObj.OrderDetailObj.Qty); } ShipmentDetailList.Add(_shipmentDetailObj); } }//if } } } } catch (Exception ex) { throw ex; } return(ShipmentDetailList); }
public IFluentShipmentDetail CreateShipmentsDetailBySalesOrderView(ShipmentView shipmentCreation) { try { var query = unitOfWork.salesOrderDetailRepository.GetIQueryableEntitiesBySalesOrderId(shipmentCreation.SalesOrderId ?? 0); List <ShipmentDetail> list = new List <ShipmentDetail>(); foreach (var item in query) { Task <ItemMaster> itemMasterTask = Task.Run(async() => await unitOfWork.itemMasterRepository.GetEntityById(item.ItemId)); Task <NextNumber> nnShipmentDetailTask = Task.Run(async() => await unitOfWork.nextNumberRepository.GetNextNumber(TypeOfShipmentDetail.ShipmentsDetailNumber.ToString())); Task.WaitAll(itemMasterTask, nnShipmentDetailTask); ShipmentDetail shipmentsDetail = new ShipmentDetail() { ShipmentDetailNumber = nnShipmentDetailTask.Result.NextNumberValue, ItemId = item.ItemId, Quantity = item.Quantity ?? 0, Amount = item.Amount, SalesOrderDetailId = item.SalesOrderDetailId, QuantityShipped = item.QuantityShipped ?? 0, AmountShipped = item.Amount, ShippedDate = shipmentCreation.ShipmentDate, Note = "", UnitPrice = itemMasterTask.Result.UnitPrice, Weight = itemMasterTask.Result.Weight ?? 0, WeightUnitOfMeasure = itemMasterTask.Result.WeightUnitOfMeasure, Volume = itemMasterTask.Result.Volume ?? 0, VolumeUnitOfMeasure = itemMasterTask.Result.VolumeUnitOfMeasure }; ItemsAdjustedQuantityShippedStruct shipmentAdjustment = shipmentCreation.ItemsAdjustedQuantityShipped.Where(e => e.SalesOrderDetailId == item.SalesOrderDetailId).FirstOrDefault(); if (shipmentAdjustment.AdjustedQuantityShipped != 0) { shipmentsDetail.QuantityShipped = shipmentAdjustment.AdjustedQuantityShipped; shipmentsDetail.AmountShipped = shipmentAdjustment.AdjustedAmountShipped; } list.Add(shipmentsDetail); } AddShipmentDetails(list); return(this as IFluentShipmentDetail); } catch (Exception ex) { throw new Exception("CreateShipmentsDetailBySalesOrderView", ex); } }
private void shipmentView_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1) { if (shipmentView.Columns[e.ColumnIndex].Name == "detailButton") { int id = Int32.Parse(shipmentView.Rows[e.RowIndex].Cells[0].Value.ToString()); ShipmentDetail sd = new ShipmentDetail(id); sd.Text += " č." + id; using (sd) { sd.ShowDialog(); } } } }
public async Task <bool> ExecutedAsync(ShipmentDetail shipmentDetail) { try { if (await db.ShipmentDetails.AnyAsync(x => x.Id == shipmentDetail.Id)) { db.Entry(shipmentDetail).State = EntityState.Modified; } await db.SaveChangesAsync(); return(true); } catch (Exception ex) { return(false); } }
public ShipmentDetailEntity(ShipmentDetail ShipmentDetail, params object[] args) : base(ShipmentDetail) { foreach (object arg in args) { if (arg is City City) { CityEntity = new CityEntity(City); } if (arg is Country Country) { CountryEntity = new CountryEntity(Country); } if (arg is Customer Customer) { CustomerEntity = new CustomerEntity(Customer); } if (arg is ICollection <Order> Orders) { OrderEntities = Orders.Select(model => new OrderEntity(model, model.Customer)).ToList(); } } }
public IFluentShipmentDetail DeleteShipmentDetail(ShipmentDetail deleteObject) { unitOfWork.shipmentDetailRepository.DeleteObject(deleteObject); this.processStatus = CreateProcessStatus.Delete; return(this as IFluentShipmentDetail); }
//public IShipmentService ShipmentService { get; set; } public bool Create(ShipmentDetailViewModel model, IDataSourceError error) { var shipmentDetail = new ShipmentDetail { ShipmentId = model.ShipmentId, ProductId = Convert.ToInt32(model.Product.Value), Quantity = model.Quantity }; if (model.ProductDetail != null && !string.IsNullOrEmpty(model.ProductDetail.Value)) { shipmentDetail.ProductDetailId = Convert.ToInt32(model.ProductDetail.Value); } // 存量檢查 int quantity = 0, inventory = 0, safeStock = 0; // 已出貨量, 已進貨量, 安全存量 if (model.ProductDetail != null && !string.IsNullOrEmpty(model.ProductDetail.Value)) { int productDetailId = Convert.ToInt32(model.ProductDetail.Value); // 已出貨量 foreach (var sd in this.DbContext.ShipmentDetails.Where(d => d.ProductDetailId == productDetailId)) { quantity += sd.Quantity; } // 已進貨量 foreach (var pd in this.DbContext.PurchaseDetails.Where(d => d.ProductDetailId == productDetailId)) { inventory += pd.Inventory; } // 安全存量 var productDetail = this.DbContext.ProductDetails.Where(d => d.ProductDetailId == productDetailId).SingleOrDefault(); safeStock = productDetail.SafeStock; shipmentDetail.SubtotalAmount = model.Quantity * productDetail.Price; } else if (model.Product != null && !string.IsNullOrEmpty(model.Product.Value)) { int productId = Convert.ToInt32(model.Product.Value); // 已出貨量 foreach (var sd in this.DbContext.ShipmentDetails.Where(d => d.ProductId == productId)) { quantity += sd.Quantity; } // 已進貨量 foreach (var pd in this.DbContext.PurchaseDetails.Where(d => d.ProductId == productId)) { inventory += pd.Inventory; } // 安全存量 var product = this.DbContext.Products.Where(p => p.ProductId == productId).SingleOrDefault(); safeStock = product.SafeStock.Value; shipmentDetail.SubtotalAmount = model.Quantity * product.Price.Value; } //TransactionScope transaction = new TransactionScope(); this.DbContext.ShipmentDetails.Add(shipmentDetail); var result = false; if (inventory >= (quantity + model.Quantity)) { if ((inventory - (quantity + model.Quantity)) < safeStock) { error.Error.AppendLine("存貨數量低於安全數量,但可出貨。"); } try { this.DbContext.SaveChanges(); model.ShipmentDetailId = shipmentDetail.ShipmentDetailId; model.SubtotalAmount = shipmentDetail.SubtotalAmount; result = true; } catch { } //if (result) // result = this.ShipmentService.RefreshShipment(shipmentDetail.ShipmentId) ?? false; } else { error.Error.AppendLine("出貨超過存貨數量,無法出貨。"); } //if (result) // transaction.Complete(); //transaction.Dispose(); return(result); }
public OperationsStatus InsertShipmentDetail(ShipmentDetail shipmentDetailObj) { return(_shipmentRepository.InsertShipmentDetail(shipmentDetailObj)); }
public ShipmentDetail CreateShipmentDetail(ShipmentDetailInsert shipmentdetail) { using (SqlConnection connection = new SqlConnection(DefaultConnection)) { connection.Open(); SqlTransaction transaction = connection.BeginTransaction(); ShipmentDetail shipmentDetail = new ShipmentDetail(); DynamicParameters p = new DynamicParameters(); p.Add("businessid", shipmentdetail.Shipment.BusinessID); p.Add("shipperid", shipmentdetail.Shipment.ShipperID); p.Add("customerid", shipmentdetail.Shipment.CustomerID); p.Add("originffw", shipmentdetail.Shipment.OriginFFW); p.Add("origin3pl", shipmentdetail.Shipment.Origin3PL); p.Add("destinationffw", shipmentdetail.Shipment.DestinationFFW); p.Add("destination3pl", shipmentdetail.Shipment.Destination3PL); p.Add("hblnumber", shipmentdetail.Shipment.HBLNumber); p.Add("mblnumber", shipmentdetail.Shipment.MBLNumber); p.Add("containernumber", shipmentdetail.Shipment.ContainerNumber); p.Add("etd", shipmentdetail.Shipment.ETD); p.Add("eta", shipmentdetail.Shipment.ETA); p.Add("txl", shipmentdetail.Shipment.TXL); p.Add("isffiled", shipmentdetail.Shipment.ISFFiled); p.Add("deliverylocationid", shipmentdetail.Shipment.DeliveryLocationID); p.Add("status", shipmentdetail.Shipment.Status); p.Add("memo", shipmentdetail.Shipment.Memo); p.Add("shipperreference", shipmentdetail.Shipment.ShipperReference); p.Add("createdby", shipmentdetail.Shipment.CreatedBy); Shipment shipment = connection.Query <Shipment>("spCreateShipment", p, transaction, commandType: CommandType.StoredProcedure).Single(); shipmentDetail.Shipment = shipment; foreach (ShipmentLineInsert _ShipmentLine in shipmentdetail.ShipmentLines) { DynamicParameters p2 = new DynamicParameters(); p2.Add("shipmentid", shipment.ShipmentID); ShipmentLine shipmentLine = connection.Query <ShipmentLine>("spCreateShipmentLine", p2, transaction, commandType: CommandType.StoredProcedure).Single(); shipmentDetail.ShipmentLines.Add(shipmentLine); } foreach (ShipmentPackageInsert _ShipmentPackage in shipmentdetail.ShipmentPackages) { DynamicParameters p2 = new DynamicParameters(); p2.Add("shipmentid", shipment.ShipmentID); ShipmentPackage shipmentPackge = connection.Query <ShipmentPackage>("spCreateShipmentPackage", p2, transaction, commandType: CommandType.StoredProcedure).Single(); shipmentDetail.ShipmentPackages.Add(shipmentPackge); } foreach (ShipmentFeeInsert _ShipmentFee in shipmentdetail.ShipmentFees) { DynamicParameters p2 = new DynamicParameters(); p2.Add("shipmentid", shipment.ShipmentID); ShipmentFee shipmentFee = connection.Query <ShipmentFee>("spCreateShipmentFee", p2, transaction, commandType: CommandType.StoredProcedure).Single(); shipmentDetail.ShipmentFees.Add(shipmentFee); } foreach (ShipmentContactInsert _ShipmentContact in shipmentdetail.ShipmentContacts) { DynamicParameters p2 = new DynamicParameters(); p2.Add("shipmentid", shipment.ShipmentID); ShipmentContact shipmentContact = connection.Query <ShipmentContact>("spCreateShipmentContact", p2, transaction, commandType: CommandType.StoredProcedure).Single(); shipmentDetail.ShipmentContacts.Add(shipmentContact); } transaction.Commit(); return(shipmentDetail); } }
public void test() { int senderid = 123456789; int receiverid = 123456781; Custommer[] cust = new Custommer[] { new Custommer() { ID = 123456789, Name = "John_Sender" }, new Custommer() { ID = 123456781, Name = "Bob_Receiver" } }; Shipments[] shipments = new Shipments[] { new Shipments() { ID = 150, SenderID = 123456789, ReceiverID = 123456781, ReceivingDate = new DateTime(2016, 09, 01), DeliveryDate = new DateTime(2016, 09, 02), Status = "Delivered" }, }; ShipmentDetail[] shipmentdetails = new ShipmentDetail[] { new ShipmentDetail() { ShipmentID = 150, Weight = 25.00, Volume = 25.00, Type = "Whatever", Cost = 25.00, Distance = 25.00 }, }; var q1 = from _shipment in shipments join _shipmentdetail in shipmentdetails on _shipment.ID equals _shipmentdetail.ShipmentID where _shipment.SenderID == senderid && _shipment.ReceiverID == receiverid select new { ShipmentID = _shipment.ID, Status = _shipment.Status, SenderID = _shipment.SenderID, SenderName = cust.Where(s => s.ID == _shipment.SenderID).Select(s => s.Name).FirstOrDefault(), ReceiverID = _shipment.ReceiverID, ReceiverName = cust.Where(s => s.ID == _shipment.ReceiverID).Select(s => s.Name).FirstOrDefault(), }; var q2 = q1.First(); Console.WriteLine ( "Shipment Id = " + q2.ShipmentID.ToString() + "\n" + "Status = " + q2.Status + "\n" + "Sender ID = " + q2.SenderID + "\n" + "SenderName = " + q2.SenderName + "\n" + "Receiver ID = " + q2.ReceiverID + "\n" + "Receiver Name = " + q2.ReceiverName ); }
public ShipmentDetailEntity Get(EmployeeEntity EmployeeEntity, Guid ShipmentDetailId) { ShipmentDetail ShipmentDetail = UnitOfWork.ShipmentDetailRepository.Get(ShipmentDetailId); return(new ShipmentDetailEntity(ShipmentDetail, ShipmentDetail.Country, ShipmentDetail.City, ShipmentDetail.Customer)); }
public IFluentShipmentDetail AddShipmentDetail(ShipmentDetail newObject) { unitOfWork.shipmentDetailRepository.AddObject(newObject); this.processStatus = CreateProcessStatus.Insert; return(this as IFluentShipmentDetail); }
public async Task <IActionResult> UpdateShipmentDetailAsync([FromBody] ShipmentDetail shipmentDetail) { return(new ObjectResult(await updateShipmentDetailCommand.ExecutedAsync(shipmentDetail))); }