private Deliveryman loadCurrentUsersDeliverymanIdIntoBuySellDoc(BuySellDoc buySellDoc) { //get the deliveryman Id for the current user. Deliveryman deliveryman = DeliverymanBiz.GetPlayerFor(UserId); deliveryman.IsNullThrowException(); //This is used in View OrderList to determine if the current user is the deliveryman //who is to accept the courier order request. buySellDoc.CurrentUser_DeliverymanId = deliveryman.Id; return(deliveryman); }
private void deliveryman_Makes_Bid_To_Pickup(BuySellDoc buySellDoc) { if (UserId.IsNullOrWhiteSpace()) { return; } if (buySellDoc.FreightOfferDecimal > 0) { //we have an offer DateParameter dp = new DateParameter(); dp.BeginDate = buySellDoc.PleasePickupOnDate_Start; dp.EndDate = buySellDoc.PleasePickupOnDate_End; if (dp.IsDateWithinBeginAndEndDatesInclusive(buySellDoc.OfferedPickupOnDate)) { string buySellDocId = buySellDoc.Id; buySellDoc = Find(buySellDocId); buySellDoc.IsNullThrowException(); //the pick up is today or later. //the user is the deliveryman here Deliveryman deliveryman = DeliverymanBiz.GetPlayerFor(UserId); deliveryman.IsNullThrowException(); //create an offer FreightOfferTrx frtOff = new FreightOfferTrx( buySellDoc.Id, deliveryman.Id, buySellDoc.FreightOfferDecimal, buySellDoc.OfferedPickupOnDate, buySellDoc.ExpectedDeliveryDate, buySellDoc.CommentByDeliveryman, buySellDoc.VehicalTypeOfferedId); //used later frtOff.Deliveryman = deliveryman; frtOff.BuySellDoc = buySellDoc; //we will only create if there is not one bid from this deliveryman //for this document. If there is already a bid, then all fields will be updated. //the change will only be allowed if the status of the buyselldoc is //check to see if a bid already exists. //this locates an earlier bid and then updates it. FreightOfferTrx frtOffTrxFound = FreightOfferTrxBiz.FindAll().FirstOrDefault(x => x.BuySellDocId == buySellDocId && x.DeliverymanId == deliveryman.Id); if (frtOffTrxFound.IsNull()) { //create a new bid. buySellDoc.FreightOfferTrxs.Add(frtOff); FreightOfferTrxBiz.Create(frtOff); } else { //update the old bid. frtOffTrxFound.UpdatePropertiesDuringModify(frtOff as ICommonWithId); FreightOfferTrxBiz.Update(frtOffTrxFound); } } } }
IQueryable <BuySellDoc> getByDocumentType_For(string userId, IQueryable <BuySellDoc> iq_allOrders, BuySellDocumentTypeENUM buySellDocumentTypeEnum) { //userId.IsNullOrWhiteSpaceThrowArgumentException("You are not logged in."); switch (buySellDocumentTypeEnum) { case BuySellDocumentTypeENUM.Sale: { try { //all orders are returned because this is the admin //if (userId.IsNullOrWhiteSpace()) // return iq_allOrders; if (userId.IsNullOrWhiteSpace()) { return(BuySellDoc.IQueryable_GetSaleDocs(iq_allOrders, "")); } Owner owner = OwnerBiz.GetPlayerFor(userId); owner.IsNullThrowException("No Owner"); return(BuySellDoc.IQueryable_GetSaleDocs(iq_allOrders, owner.Id)); } catch (Exception e) { ErrorsGlobal.Add("Problem getting sales.", MethodBase.GetCurrentMethod(), e); throw new Exception(ErrorsGlobal.ToString()); } } case BuySellDocumentTypeENUM.Purchase: { try { //all orders are returned because this is the admin //if (userId.IsNullOrWhiteSpace()) // return iq_allOrders; if (userId.IsNullOrWhiteSpace()) { return(BuySellDoc.IQueryable_GetPurchaseDocs(iq_allOrders, "")); } Customer customer = CustomerBiz.GetPlayerFor(userId); customer.IsNullThrowException("Customer"); return(BuySellDoc.IQueryable_GetPurchaseDocs(iq_allOrders, customer.Id)); } catch (Exception e) { ErrorsGlobal.Add("Problem getting purchases", MethodBase.GetCurrentMethod(), e); throw new Exception(ErrorsGlobal.ToString()); } } case BuySellDocumentTypeENUM.Delivery: { try { //all orders are returned because this is the admin if (userId.IsNullOrWhiteSpace()) { return(BuySellDoc.IQueryable_GetDeliveryDocs(iq_allOrders, "")); } Deliveryman deliveryMan = DeliverymanBiz.GetPlayerFor(userId); deliveryMan.IsNullThrowException("deliveryMan"); return(BuySellDoc.IQueryable_GetDeliveryDocs(iq_allOrders, deliveryMan.Id)); } catch (Exception e) { ErrorsGlobal.Add("Problem getting purchases", MethodBase.GetCurrentMethod(), e); throw new Exception(ErrorsGlobal.ToString()); } } case BuySellDocumentTypeENUM.Salesman: { try { if (userId.IsNullOrWhiteSpace()) { return(BuySellDoc.IQueryable_GetSalesmanDocs(iq_allOrders, "")); } Salesman salesman = SalesmanBiz.GetPlayerFor(userId); salesman.IsNullThrowException("Salesman"); return(BuySellDoc.IQueryable_GetSalesmanDocs(iq_allOrders, salesman.Id)); } catch (Exception e) { ErrorsGlobal.Add("Problem getting purchases", MethodBase.GetCurrentMethod(), e); throw new Exception(ErrorsGlobal.ToString()); } } case BuySellDocumentTypeENUM.Unknown: default: throw new Exception("Unknown document type"); } }