public List<SpotOrderInfo> GetSpotOrders(OrderQry aOrderQry) { List<BOC.Entities.OrderData> lOrders = _BOCWebDBContext.OrderDatas .Where(e => e.BuyOrSell == aOrderQry.OrderSide && e.FutureOrSpot == aOrderQry.OrderType) .OrderByDescending(e => e.PostDate) .Skip(aOrderQry.pagesize * (aOrderQry.page - 1)) .Take(aOrderQry.pagesize).ToList(); List<SpotOrderInfo> SpotOrderList = new List<SpotOrderInfo>(); foreach (BOC.Entities.OrderData orderdata in lOrders) { SpotOrderInfo lSpotOrderInfo = new SpotOrderInfo(); lSpotOrderInfo.OrderDataID = orderdata.OrderDataID; lSpotOrderInfo.Cuts = orderdata.Cuts; lSpotOrderInfo.SubCuts = orderdata.SubCuts; lSpotOrderInfo.Grade = orderdata.Grade; lSpotOrderInfo.SubGrade = orderdata.SubGrade; lSpotOrderInfo.Origin = orderdata.Origin; if(aOrderQry.ShowEstablishmentNumber) { lSpotOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; } else { lSpotOrderInfo.EstablishmentNumber = "******"; } lSpotOrderInfo.Halal = orderdata.Halal; lSpotOrderInfo.Packing = orderdata.Packing; lSpotOrderInfo.Packedon = orderdata.Packedon; lSpotOrderInfo.ExpirationDate = orderdata.ExpirationDate; lSpotOrderInfo.Quantity = orderdata.Quantity; if (aOrderQry.ShowPrice) { lSpotOrderInfo.Price = orderdata.Price.ToString().Trim('0').Trim('.'); } else { lSpotOrderInfo.Price = "******"; } lSpotOrderInfo.PhoneContact = orderdata.PhoneContact; lSpotOrderInfo.StorageLocation = orderdata.StorageLocation; lSpotOrderInfo.Delivery = orderdata.Delivery; lSpotOrderInfo.Validity = orderdata.Validity; lSpotOrderInfo.PostDate = orderdata.PostDate; lSpotOrderInfo.PicLink = orderdata.PicLink; lSpotOrderInfo.SendCompanyName = orderdata.SendCompanyName; lSpotOrderInfo.BoneinOrLess = orderdata.BoneinOrLess; lSpotOrderInfo.OxType = orderdata.OxType; lSpotOrderInfo.OxAge = orderdata.OxAge; lSpotOrderInfo.RaiseType = orderdata.RaiseType; lSpotOrderInfo.RaiseDays = orderdata.RaiseDays; lSpotOrderInfo.ShowCount = _BOCWebDBContext.ShowOrderInfos.Where(e => e.OrderDataID == orderdata.OrderDataID).Count(); SpotOrderList.Add(lSpotOrderInfo); } return SpotOrderList; }
public List<FutureOrderInfo> GetFutureOrders(OrderQry aOrderQry) { List<BOC.Entities.OrderData> lOrders = _BOCWebDBContext.OrderDatas .Where(e => e.BuyOrSell == aOrderQry.OrderSide && e.FutureOrSpot == aOrderQry.OrderType) .OrderByDescending(e => e.PostDate) .Skip(aOrderQry.pagesize * (aOrderQry.page - 1)) .Take(aOrderQry.pagesize).ToList(); List<FutureOrderInfo> FutureOrderList = new List<FutureOrderInfo>(); foreach (BOC.Entities.OrderData orderdata in lOrders) { FutureOrderInfo lFutureOrderInfo = new FutureOrderInfo(); lFutureOrderInfo.OrderDataID = orderdata.OrderDataID; lFutureOrderInfo.Cuts = orderdata.Cuts; lFutureOrderInfo.SubCuts = orderdata.SubCuts; lFutureOrderInfo.Grade = orderdata.Grade; lFutureOrderInfo.SubGrade = orderdata.SubGrade; lFutureOrderInfo.Origin = orderdata.Origin; if (aOrderQry.ShowEstablishmentNumber) { //lFutureOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; switch (aOrderQry.UserRoleID) { case 1: break; case 2: if (aOrderQry.UserName == orderdata.SendCompanyName) { lFutureOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; } else { BOC.Entities.OrderReturn lOrderReturn = _BOCWebDBContext.OrderReturns.Where(e => e.OrderDataID == orderdata.OrderDataID && e.UserName == aOrderQry.UserName).FirstOrDefault(); if (lOrderReturn != null) { if (lOrderReturn.RetrurnStatus == 1) { lFutureOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; } else { if (orderdata.IsOpen) { lFutureOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; } else { if (orderdata.EstablishmentNumber != null && orderdata.EstablishmentNumber != "") { lFutureOrderInfo.EstablishmentNumber = "******"; } else { lFutureOrderInfo.EstablishmentNumber = ""; } } } } else { if (orderdata.IsOpen) { lFutureOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; } else { if (orderdata.EstablishmentNumber != null && orderdata.EstablishmentNumber != "") { lFutureOrderInfo.EstablishmentNumber = "******"; } else { lFutureOrderInfo.EstablishmentNumber = ""; } } } } break; case 3: if (orderdata.IsOpen) { lFutureOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; } else { if (orderdata.EstablishmentNumber != null && orderdata.EstablishmentNumber != "") { lFutureOrderInfo.EstablishmentNumber = "******"; } else { lFutureOrderInfo.EstablishmentNumber = ""; } } break; case 4: if (aOrderQry.UserName == orderdata.SendCompanyName) { lFutureOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; } else { BOC.Entities.OrderReturn lOrderReturn = _BOCWebDBContext.OrderReturns.Where(e => e.OrderDataID == orderdata.OrderDataID && e.UserName == aOrderQry.UserName).FirstOrDefault(); if (lOrderReturn != null) { if (lOrderReturn.RetrurnStatus == 1) { lFutureOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; } else { if (orderdata.IsOpen) { lFutureOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; } else { if (orderdata.EstablishmentNumber != null && orderdata.EstablishmentNumber != "") { lFutureOrderInfo.EstablishmentNumber = "******"; } else { lFutureOrderInfo.EstablishmentNumber = ""; } } } } else { if (orderdata.IsOpen) { lFutureOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; } else { if (orderdata.EstablishmentNumber != null && orderdata.EstablishmentNumber != "") { lFutureOrderInfo.EstablishmentNumber = "******"; } else { lFutureOrderInfo.EstablishmentNumber = ""; } } } } break; case 5: if (orderdata.EstablishmentNumber != null && orderdata.EstablishmentNumber != "") { if (orderdata.IsOpen) { lFutureOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; } else { lFutureOrderInfo.EstablishmentNumber = "******"; } } else { lFutureOrderInfo.EstablishmentNumber = ""; } break; } } else { if (orderdata.IsOpen) { switch (aOrderQry.UserRoleID) { case 1: break; case 2: lFutureOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; break; case 3: lFutureOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; break; case 4: lFutureOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; break; case 5: lFutureOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; break; } //lFutureOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; } else { if (aOrderQry.UserName == orderdata.SendCompanyName) { lFutureOrderInfo.EstablishmentNumber = orderdata.EstablishmentNumber; } else { lFutureOrderInfo.EstablishmentNumber = "******"; } } } lFutureOrderInfo.Halal = orderdata.Halal; lFutureOrderInfo.Packing = orderdata.Packing; lFutureOrderInfo.Packedon = orderdata.Packedon; lFutureOrderInfo.ExpirationDate = orderdata.ExpirationDate; lFutureOrderInfo.Quantity = orderdata.Quantity; lFutureOrderInfo.ShippingTerm = orderdata.ShippingTerm; lFutureOrderInfo.TargetPriceNegotiate = orderdata.TargetPriceNegotiate; if(aOrderQry.UserName != null && aOrderQry.UserName != "") { if(aOrderQry.UserName == orderdata.SendCompanyName) { lFutureOrderInfo.TargetPrice = orderdata.TargetPrice.ToString().Trim('0').Trim('.'); } else { switch(aOrderQry.UserRoleID) { case 1: break; case 2: if (aOrderQry.OrderSide == 1) { if (orderdata.IsOpen) { lFutureOrderInfo.TargetPrice = orderdata.TargetPrice.ToString().Trim('0').Trim('.'); } else { lFutureOrderInfo.TargetPrice = "******"; } } else { lFutureOrderInfo.TargetPrice = orderdata.TargetPrice.ToString().Trim('0').Trim('.'); } break; case 3: if (aOrderQry.OrderSide == 1) { if (orderdata.IsOpen) { lFutureOrderInfo.TargetPrice = orderdata.TargetPrice.ToString().Trim('0').Trim('.'); } else { lFutureOrderInfo.TargetPrice = "******"; } } else { lFutureOrderInfo.TargetPrice = orderdata.TargetPrice.ToString().Trim('0').Trim('.'); } break; case 4: if (aOrderQry.OrderSide == 1) { lFutureOrderInfo.TargetPrice = orderdata.TargetPrice.ToString().Trim('0').Trim('.'); } else { if (orderdata.IsOpen) { lFutureOrderInfo.TargetPrice = orderdata.TargetPrice.ToString().Trim('0').Trim('.'); } else { lFutureOrderInfo.TargetPrice = "******"; } } break; case 5: if (orderdata.IsOpen) { lFutureOrderInfo.TargetPrice = orderdata.TargetPrice.ToString().Trim('0').Trim('.'); } else { lFutureOrderInfo.TargetPrice = "******"; } //lFutureOrderInfo.TargetPrice = "******"; break; } } } else { lFutureOrderInfo.TargetPrice = "******"; } /* if (aOrderQry.ShowPrice) { lFutureOrderInfo.TargetPrice = orderdata.TargetPrice.ToString(); } else { lFutureOrderInfo.TargetPrice = "******"; } */ lFutureOrderInfo.Payment = orderdata.Payment; lFutureOrderInfo.Shipment = orderdata.Shipment; lFutureOrderInfo.Validity = orderdata.Validity; lFutureOrderInfo.PostDate = orderdata.PostDate; lFutureOrderInfo.Status = orderdata.Status; lFutureOrderInfo.PicLink = orderdata.PicLink; lFutureOrderInfo.SendCompanyName = orderdata.SendCompanyName; lFutureOrderInfo.IsPaymentTT = orderdata.IsPaymentTT; lFutureOrderInfo.PaymentFirstPercentage = orderdata.PaymentFirstPercentage; lFutureOrderInfo.PaymentFirst = orderdata.PaymentFirst; lFutureOrderInfo.PaymentSecondPercentage = orderdata.PaymentSecondPercentage; lFutureOrderInfo.PaymentSecond = orderdata.PaymentSecond; lFutureOrderInfo.BoneinOrLess = orderdata.BoneinOrLess; lFutureOrderInfo.PhoneContact = orderdata.PhoneContact; lFutureOrderInfo.IsOpen = orderdata.IsOpen; lFutureOrderInfo.OxType = orderdata.OxType; lFutureOrderInfo.OxAge = orderdata.OxAge; lFutureOrderInfo.RaiseType = orderdata.RaiseType; lFutureOrderInfo.RaiseDays = orderdata.RaiseDays; lFutureOrderInfo.ShowCount = _BOCWebDBContext.ShowOrderInfos.Where(e => e.OrderDataID == orderdata.OrderDataID).Count(); int lShowInterestCount = 0; int lReturnInterestCount = 0; int lNotReturnInterestCount = 0; List<BOC.Entities.OrderReturn> lOrderReturns = _BOCWebDBContext.OrderReturns.Where(e => e.OrderDataID == orderdata.OrderDataID).ToList(); foreach (BOC.Entities.OrderReturn orderreturn in lOrderReturns) { lShowInterestCount++; if (orderreturn.RetrurnStatus == 1) { lReturnInterestCount++; } if (orderreturn.RetrurnStatus == 0) { lNotReturnInterestCount++; } } lFutureOrderInfo.ShowInterestCount = lShowInterestCount; lFutureOrderInfo.ReturnInterestCount = lReturnInterestCount; lFutureOrderInfo.NotReturnsInterestCount = lNotReturnInterestCount; FutureOrderList.Add(lFutureOrderInfo); } return FutureOrderList; }
public int GetOrderCount(OrderQry aOrderQry) { int lCount = _BOCWebDBContext.OrderDatas.Where(e => e.BuyOrSell == aOrderQry.OrderSide && e.FutureOrSpot == aOrderQry.OrderType).Count(); return lCount; }