public void Load_Current_User_As_Delyman_Id_Into_BuySellDoc_And_UpdateVarsWithEarlierOffer(BuySellDoc buySellDoc) { //check to see if the user has bid on this before. If yes, then find it and add the values. Deliveryman deliveryman = loadCurrentUsersDeliverymanIdIntoBuySellDoc(buySellDoc); FreightOfferTrx earlierOfferByUser = FreightOfferTrxBiz.FindAll().FirstOrDefault(x => x.BuySellDocId == buySellDoc.Id && x.DeliverymanId == deliveryman.Id); if (earlierOfferByUser.IsNull()) { } else { //an earlier bid has been found buySellDoc.UpdateFreightBidVars(earlierOfferByUser); } }
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); } } } }