public BuySellDocBiz(IRepositry <BuySellDoc> entityDal, BuySellItemBiz buySellItemBiz, BizParameters bizParameters, OwnerBiz ownerBiz, CustomerBiz customerBiz, ShopBiz shopBiz, DeliverymanBiz deliverymanBiz, FreightOfferTrxBiz freightOfferTrxBiz, VehicalTypeBiz vehicalTypeBiz, MessageBiz messageBiz, PeopleMessageBiz peopleMessageBiz, SalesmanBiz salesmanBiz, BuySellDocHistoryBiz buySellDocHistoryBiz) : base(entityDal, bizParameters) { _ownerBiz = ownerBiz; _customerBiz = customerBiz; _shopBiz = shopBiz; _buySellBiz = entityDal as BuySellDocBiz; _buySellItemBiz = buySellItemBiz; _freightOfferTrxBiz = freightOfferTrxBiz; _deliverymanBiz = deliverymanBiz; _vehicalTypeBiz = vehicalTypeBiz; _messageBiz = messageBiz; _peopleMessageBiz = peopleMessageBiz; _salesmanBiz = salesmanBiz; _buySellDocHistoryBiz = buySellDocHistoryBiz; }
private void createMessageFor(RejectCancelDeleteInbetweenClass rcdbc, BuySellDoc buySellDoc) { string fromPersonId = ""; string toPersonId = ""; Person fromPerson = null; List <string> listOfToPeople = new List <string>(); string buySellDocId = buySellDoc.Id; Person ownerPerson = OwnerBiz.GetPersonForPlayer(buySellDoc.OwnerId); Person customerPerson = CustomerBiz.GetPersonForPlayer(buySellDoc.CustomerId); ownerPerson.IsNullThrowException(); customerPerson.IsNullThrowException(); switch (buySellDoc.BuySellDocumentTypeEnum) { case BuySellDocumentTypeENUM.Sale: fromPersonId = ownerPerson.Id; fromPerson = ownerPerson; toPersonId = customerPerson.Id; listOfToPeople.Add(toPersonId); break; case BuySellDocumentTypeENUM.Purchase: toPersonId = ownerPerson.Id; fromPersonId = customerPerson.Id; fromPerson = customerPerson; listOfToPeople.Add(toPersonId); break; case BuySellDocumentTypeENUM.Delivery: Person deliveryPerson = DeliverymanBiz.GetPersonForPlayer(buySellDoc.DeliverymanId); deliveryPerson.IsNullThrowException(); fromPersonId = deliveryPerson.Id; fromPerson = deliveryPerson; listOfToPeople.Add(ownerPerson.Id); listOfToPeople.Add(customerPerson.Id); break; case BuySellDocumentTypeENUM.Unknown: default: throw new Exception("Unknown document type"); } Message message = new Message( fromPersonId, fromPerson, listOfToPeople, rcdbc.Subject, rcdbc.Comment, MessageENUM.Free, null); if (buySellDoc.Messages.IsNull()) { buySellDoc.Messages = new List <Message>(); } buySellDoc.Messages.Add(message); message.BuySellDocId = buySellDoc.Id; message.ListOfToPeopleId.IsNullOrEmptyThrowException(); foreach (var pplId in message.ListOfToPeopleId) { Person person = PersonBiz.Find(pplId); person.IsNullThrowException(); PeopleMessage pplMsg = new PeopleMessage(); pplMsg.IsNullThrowException(); pplMsg.PersonId = pplId; pplMsg.Person = person; pplMsg.MessageId = message.Id; PeopleMessageBiz.Create(pplMsg); } MessageBiz.Create(message); }