public async Task <string> CreateCase(LibraryVolunteeringEnquiry enquiry) { var response = await _verintServiceGateway.CreateCase(enquiry.MapToCase( _verintConfiguration.EventCode, _verintConfiguration.Classification)); if (!response.IsSuccessStatusCode) { throw new Exception("LibraryVolunteeringEnquiryService.CreateCase: VerintServiceGateway status code indicated the case was not created."); } if (!string.IsNullOrEmpty(enquiry.Email)) { _ = _mailingServiceGateway.Send(new Mail { Template = EMailTemplate.LibraryVolunteeringEnquiry, Payload = JsonConvert.SerializeObject(new { enquiry.FirstName, Reference = response.ResponseContent, RecipientAddress = enquiry.Email, Subject = "Library Volunteering Enquiry" }) }); } return(response.ResponseContent); }
public static Case MapToCase(this LibraryVolunteeringEnquiry model, int eventCode, string classification) { var description = new DescriptionBuilder() .Add("Selected Interests", model.InterestList, ", ") .Add("Selected Locations", model.PreferredLocationList, ", ") .Add("Hours", model.NumberOfHours.ToString()) .Add("Days can't work", model.NotAvailableList, ", "); if (!string.IsNullOrEmpty(model.AdditionalInfo)) { description.Add("Extra Information", model.AdditionalInfo); } return(new Case { EventCode = eventCode, Classification = classification, EventTitle = "Volunteering", Description = description.Build(), AssociatedWithBehaviour = AssociatedWithBehaviourEnum.Individual, Customer = new Customer { Forename = model.FirstName, Surname = model.LastName, Email = model.Email, Telephone = model.Phone, Address = new Address { AddressLine1 = model.CustomersAddress.AddressLine1, AddressLine2 = model.CustomersAddress.AddressLine2, AddressLine3 = model.CustomersAddress.Town, Postcode = model.CustomersAddress.Postcode, Reference = model.CustomersAddress.PlaceRef, UPRN = model.CustomersAddress.PlaceRef } } }); }
public async Task <IActionResult> Post([FromBody] LibraryVolunteeringEnquiry libraryVolunteeringEnquiry) => Ok(await _libraryVolunteeringEnquiryService.CreateCase(libraryVolunteeringEnquiry));