public async Task <string> CreateCase(ParkingEnforcementRequest parkingEnforcementRequest) { var crmCase = CreateCrmCaseObject(parkingEnforcementRequest); try { var response = await _VerintServiceGateway.CreateCase(crmCase); if (!response.IsSuccessStatusCode) { throw new Exception("Status code not successful"); } Person person = new Person { FirstName = parkingEnforcementRequest.FirstName, LastName = parkingEnforcementRequest.LastName, Email = parkingEnforcementRequest.Email, Phone = parkingEnforcementRequest.Phone, CustomerAddress = parkingEnforcementRequest.CustomersAddress }; _mailHelper.SendEmail(person, EMailTemplate.ParkingEnforcementRequest, response.ResponseContent); return(response.ResponseContent); } catch (Exception ex) { throw new Exception($"CRMService CreateParkingEnforcementService an exception has occurred while creating the case in verint service", ex); } }
private Case CreateCrmCaseObject(ParkingEnforcementRequest parkingEnforcementRequest) { var crmCase = new Case { EventCode = Int32.Parse(configuration.GetSection("CrmCaseSettings").GetSection("EventCode").Value), EventTitle = configuration.GetSection("CrmCaseSettings").GetSection("EventTitle").Value, Description = parkingEnforcementRequest.MoreDetails, Classification = configuration.GetSection("CrmCaseSettings").GetSection("Classification").Value, Street = new Street { Reference = parkingEnforcementRequest.StreetAddress.PlaceRef } }; if (!string.IsNullOrEmpty(parkingEnforcementRequest.FirstName) && !string.IsNullOrEmpty(parkingEnforcementRequest.LastName)) { crmCase.Customer = new Customer { Forename = parkingEnforcementRequest.FirstName, Surname = parkingEnforcementRequest.LastName }; if (!string.IsNullOrEmpty(parkingEnforcementRequest.Email)) { crmCase.Customer.Email = parkingEnforcementRequest.Email; } if (!string.IsNullOrEmpty(parkingEnforcementRequest.Phone)) { crmCase.Customer.Telephone = parkingEnforcementRequest.Phone; } if (string.IsNullOrEmpty(parkingEnforcementRequest.CustomersAddress.PlaceRef)) { crmCase.Customer.Address = new Address { AddressLine1 = parkingEnforcementRequest.CustomersAddress.AddressLine1, AddressLine2 = parkingEnforcementRequest.CustomersAddress.AddressLine2, AddressLine3 = parkingEnforcementRequest.CustomersAddress.Town, Postcode = parkingEnforcementRequest.CustomersAddress.Postcode, }; } else { crmCase.Customer.Address = new Address { Reference = parkingEnforcementRequest.CustomersAddress.PlaceRef, UPRN = parkingEnforcementRequest.CustomersAddress.PlaceRef }; } } return(crmCase); }
public async Task <IActionResult> Post([FromBody] ParkingEnforcementRequest parkingEnforcementRequest) { string result = await _parkingEnforcementService.CreateCase(parkingEnforcementRequest); return(Ok(result)); }
public async Task <HttpResponseMessage> CreateCase(ParkingEnforcementRequest request) => await PostAsync($"{CaseEndpoint}/Home", request);