public CreatePolicyResponse CreatePolicy(CreatePolicyRequest inputParameters, Broker broker) { Client client = Mapper.Map<Client>(inputParameters.RegisteredKeeper); if (inputParameters.RegisteredKeeper.IsLegalPerson) { client.LegalPerson = Mapper.Map<LegalPerson>(inputParameters.RegisteredKeeper); client.LegalPerson.Address = Mapper.Map<AddressDto>(inputParameters.RegisteredKeeper); client.LegalPerson.MailingAddress = Mapper.Map<MailingAddressDto>(inputParameters.RegisteredKeeper); } else { client.Person = Mapper.Map<Person>(inputParameters.RegisteredKeeper); client.Person.Address = Mapper.Map<AddressDto>(inputParameters.RegisteredKeeper); client.Person.MailingAddress = Mapper.Map<MailingAddressDto>(inputParameters.RegisteredKeeper); } Vehicle vehicle = Mapper.Map<Vehicle>(inputParameters.Vehicle); Policy savedPolicy = DataAccess.SavePolicy(inputParameters.QuoteGuid, client, vehicle, broker); CreatePolicyResponse result = new CreatePolicyResponse() { PolicyNumber = savedPolicy.PolicyNumber }; return result; }
/// <summary> /// Creates the policy. /// </summary> /// <param name="inputParameters">The input parameters.</param> /// <returns></returns> /// <exception cref="FaultException{ExceptionFaultContract}">new ExceptionFaultContract(CreatePolicy, not implemented, )</exception> /// <exception cref="ExceptionFaultContract">CreatePolicy;not implemented</exception> public CreatePolicyResponse CreatePolicy(CreatePolicyRequest inputParameters) { try { //to do AUTH IncomingWebRequestContext request = WebOperationContext.Current.IncomingRequest; WebHeaderCollection headers = request.Headers; //var url = HttpContext.Current.Request.Url.AbsoluteUri; Broker broker = new Broker() { ID = 1, Name = "Test" }; CreatePolicyResponse result = Wservice.CreatePolicy(inputParameters, broker); return result; } catch (Exception ex) { //throw new FaultException("CreatePolicy error description"); throw new FaultException<ExceptionFaultContract>(new ExceptionFaultContract("CreatePolicy", "Error during creating the policy", ex.Message), ""); } }