public bool AssignUserToServiceRequestHdr(string serviceRequestHdrId) { UserId.IsNullOrWhiteSpaceThrowException("Not logged in"); serviceRequestHdrId.IsNullOrWhiteSpaceThrowArgumentException(); ServiceRequestHdr srh = ServiceRequestHdrBiz.Find(serviceRequestHdrId); srh.IsNullThrowException(); if (srh.ServiceRequestStatusEnum == ServiceRequestStatusENUM.Open) { //Person userPerson = PersonBiz.GetPersonForUserId(UserId); //userPerson.IsNullThrowException(); srh.PersonToId = CurrentUserParameter.PersonId; srh.ServiceRequestStatusEnum = ServiceRequestStatusENUM.Closed; ServiceRequestHdrBiz.Update(srh); PenaltyHeader ph = setupPenaltyHeaderForServiceRequestDetail(srh); } else { throw new Exception("This item is not open"); } return(true); }
private static PenaltyHeader setupPenaltyHeaderForServiceRequestDetail(ServiceRequestHdr srh) { IServiceRequestDetail srd = ServiceRequestController.GetServiceRequestDetail(srh.RequestTypeEnum); PenaltyHeader ph = new PenaltyHeader(); ph.Amount = srd.Amount; ph.FromPersonId = srh.PersonToId; //the person who bought the name is paying ph.Comment = srd.Text; return(ph); }
private void createAndSavePenalty(BuySellDoc bsd, string reason, PersonPayingPenalty ppp, decimal totalPaymentAmount, GlobalObject globalObject) { ppp.SelfErrorCheck(); PenaltyHeader ph = new PenaltyHeader(bsd, reason, totalPaymentAmount, ppp.From.Person, true); PenaltyHeaderBiz.Create(ph); if (!ppp.Owner.Person.IsNull()) { PenaltyTrx owner = new PenaltyTrx(ppp.Owner.Person.Id, ppp.Owner.Amount, ppp.Owner.Comment, false); PenaltyHeaderBiz.AddPenaltyTrx(ph, owner); } if (!ppp.Deliveryman.Person.IsNull()) { PenaltyTrx deliveryman = new PenaltyTrx(ppp.Deliveryman.Person.Id, ppp.Deliveryman.Amount, ppp.Deliveryman.Comment, false); PenaltyHeaderBiz.AddPenaltyTrx(ph, deliveryman); } if (!ppp.Salesman_Owner.Person.IsNull()) { PenaltyTrx salesman_Owner = new PenaltyTrx(ppp.Salesman_Owner.Person.Id, ppp.Salesman_Owner.Amount, ppp.Salesman_Owner.Comment, false); PenaltyHeaderBiz.AddPenaltyTrx(ph, salesman_Owner); } if (!ppp.Salesman_Customer.Person.IsNull()) { PenaltyTrx salesman_Customer = new PenaltyTrx(ppp.Salesman_Customer.Person.Id, ppp.Salesman_Customer.Amount, ppp.Salesman_Customer.Comment, false); PenaltyHeaderBiz.AddPenaltyTrx(ph, salesman_Customer); } if (!ppp.Salesman_Deliveryman.Person.IsNull()) { PenaltyTrx salesman_Deliveryman = new PenaltyTrx(ppp.Salesman_Deliveryman.Person.Id, ppp.Salesman_Deliveryman.Amount, ppp.Salesman_Deliveryman.Comment, false); PenaltyHeaderBiz.AddPenaltyTrx(ph, salesman_Deliveryman); } if (!ppp.System_Freight.IsNull()) { PenaltyTrx system_Freight = new PenaltyTrx(ppp.System_Freight.Person.Id, ppp.System_Freight.Amount, ppp.System_Freight.Comment, false); PenaltyHeaderBiz.AddPenaltyTrx(ph, system_Freight); } if (!ppp.System_Sale.IsNull()) { PenaltyTrx system_Sale = new PenaltyTrx(ppp.System_Sale.Person.Id, ppp.System_Sale.Amount, ppp.System_Sale.Comment, false); PenaltyHeaderBiz.AddPenaltyTrx(ph, system_Sale); } if (!ppp.System_ExtraCommission.IsNull()) { PenaltyTrx system_ExtraCommission = new PenaltyTrx(ppp.System_ExtraCommission.Person.Id, ppp.System_ExtraCommission.Amount, ppp.System_ExtraCommission.Comment, false); PenaltyHeaderBiz.AddPenaltyTrx(ph, system_ExtraCommission); } PenaltyHeaderBiz.SaveChanges(); }