public HttpResponseMessage CustomerIncidentPaymentView(string incidentGUID) { HttpResponseMessage response; Services.Log.Info("Customer Incident [" + incidentGUID + "] Payment View Requested [API]"); Uri redirectURI; string paymentService; IncidentInfo paymentIncident; stranddContext context = new stranddContext(); Incident returnIncident = context.Incidents.Find(incidentGUID); if (returnIncident != null) { paymentService = "Instamojo"; //WILL ADAPT AS NEW PAYMENT SERVICES ADDED paymentIncident = new IncidentInfo(incidentGUID); } else { paymentService = "Not Found"; paymentIncident = new IncidentInfo(); } if (paymentService == "Instamojo") { string instamojoIncidentDataField = WebConfigurationManager.AppSettings["RZ_InstamojoIncidentDataField"]; // "data_Field_25373" var redirectQuery = HttpUtility.ParseQueryString(string.Empty); redirectQuery["data_readonly"] = "data_amount"; redirectQuery["embed"] = "form"; redirectQuery["data_amount"] = (paymentIncident.ServiceFee - paymentIncident.PaymentAmount).ToString(); redirectQuery["data_email"] = paymentIncident.IncidentUserInfo.Email.ToString(); redirectQuery["data_name"] = paymentIncident.IncidentUserInfo.Name.ToString(); redirectQuery["data_phone"] = paymentIncident.IncidentUserInfo.Phone.ToString(); redirectQuery[("data_" + instamojoIncidentDataField)] = incidentGUID; redirectQuery["data_hidden"] = ("data_" + instamojoIncidentDataField); string urlFullString = WebConfigurationManager.AppSettings["RZ_InstamojoBaseURL"].ToString() + "?" + redirectQuery.ToString(); redirectURI = new Uri(urlFullString); response = Request.CreateResponse(HttpStatusCode.Moved); response.Headers.Location = redirectURI; Services.Log.Info("Customer Incident Payment View [" + urlFullString + "] Returned [VIEW]"); } else { response = Request.CreateResponse("<H1>No Incident Found</H1>"); Services.Log.Warn("Customer Incident [" + incidentGUID + "] Not Found [VIEW]"); } //Return Generated Response return response; }
public static bool SendCurrentIncidentInvoiceEmail(Incident incident, ApiServices Services) { IncidentInfo invoiceIncident = new IncidentInfo(incident); if (invoiceIncident.PaymentAmount < invoiceIncident.ServiceFee) { SendGridMessage invoiceMessage = new SendGridMessage(); invoiceMessage.From = SendGridHelper.GetAppFrom(); invoiceMessage.AddTo(invoiceIncident.IncidentUserInfo.Email); invoiceMessage.Html = " "; invoiceMessage.Text = " "; invoiceMessage.Subject = "StrandD Invoice - Payment for Service Due"; invoiceMessage.EnableTemplateEngine(WebConfigurationManager.AppSettings["RZ_InvoiceTemplateID"]); invoiceMessage.AddSubstitution("%invoicestub%", new List<string> { invoiceIncident.IncidentGUID.Substring(0, 5).ToUpper() }); invoiceMessage.AddSubstitution("%incidentguid%", new List<string> { invoiceIncident.IncidentGUID }); invoiceMessage.AddSubstitution("%name%", new List<string> { invoiceIncident.IncidentUserInfo.Name }); invoiceMessage.AddSubstitution("%phone%", new List<string> { invoiceIncident.IncidentUserInfo.Phone }); invoiceMessage.AddSubstitution("%email%", new List<string> { invoiceIncident.IncidentUserInfo.Email }); invoiceMessage.AddSubstitution("%jobdescription%", new List<string> { invoiceIncident.JobCode }); invoiceMessage.AddSubstitution("%servicefee%", new List<string> { (invoiceIncident.ServiceFee - invoiceIncident.PaymentAmount).ToString() }); invoiceMessage.AddSubstitution("%datesubmitted%", new List<string> { DateTime.Now.ToShortDateString() }); invoiceMessage.AddSubstitution("%datedue%", new List<string> { (DateTime.Now.AddDays(30)).ToShortTimeString() }); invoiceMessage.AddSubstitution("%servicepaymentlink%", new List<string> { (WebConfigurationManager.AppSettings["RZ_ServiceBaseURL"].ToString() + "/view/customer/incidentpayment/" + invoiceIncident.IncidentGUID) }); // Create an Web transport for sending email. var transportWeb = new Web(SendGridHelper.GetNetCreds()); // Send the email. try { transportWeb.Deliver(invoiceMessage); Services.Log.Info("Incident Invoice Email Sent to [" + invoiceIncident.IncidentUserInfo.Email + "]"); return true; } catch (InvalidApiRequestException ex) { for (int i = 0; i < ex.Errors.Length; i++) { Services.Log.Error(ex.Errors[i]); return false; } } return false; } else { return false; } }
public IncidentStatusRequest(string incidentGUID) { IncidentInfo lookupIncident = new IncidentInfo(incidentGUID); this.IncidentGUID = lookupIncident.IncidentGUID; this.NewStatusCode = lookupIncident.StatusCode; this.ServiceFee = lookupIncident.ServiceFee; if (lookupIncident.ProviderArrivalTime != null && lookupIncident.StatusCode != "ARRIVED") { TimeSpan etaSpan = (DateTimeOffset)lookupIncident.ProviderArrivalTime - System.DateTime.Now; if (etaSpan.TotalMinutes > 1) { this.ETA = Convert.ToInt32(etaSpan.TotalMinutes); } } if (lookupIncident.StatusCode == "ARRIVED" && lookupIncident.PaymentMethod != null) { this.NewStatusCode = lookupIncident.PaymentMethod; } }
public async Task<HttpResponseMessage> UpdateCosting(IncidentCostingRequest costingRequest) { Services.Log.Info("Update Incident Costing Request [API]"); string responseText; IncidentInfo infoOutput; //Get Defaults From Configuration and overrride from Request (To be Modified in Expansions) string companyGUID = (costingRequest.ProviderIdentifierGUID == null || costingRequest.ProviderIdentifierGUID == "") ? WebConfigurationManager.AppSettings["RZ_DefaultProviderCompany"] : costingRequest.ProviderIdentifierGUID; string policyGUID = (costingRequest.CustomerIdentifierGUID == null || costingRequest.CustomerIdentifierGUID == "") ? WebConfigurationManager.AppSettings["RZ_DefaultCustomerPolicy"] : costingRequest.CustomerIdentifierGUID; stranddContext context = new stranddContext(); CostingSlab providerSlab = new CostingSlab(); providerSlab = await (from r in context.CostingSlabs where (r.IdentifierGUID == companyGUID && r.ServiceType == costingRequest.ServiceType && r.Status == "CURRENT") select r).FirstOrDefaultAsync(); if (providerSlab == null) { responseText = "Provider Company Costing Slab Not Found"; Services.Log.Warn(responseText); } else { IncidentController.SaveCostingSlabAsync(costingRequest, providerSlab, "PROVIDER", Services); } CostingSlab customerSlab = new CostingSlab(); customerSlab = await (from r in context.CostingSlabs where (r.IdentifierGUID == policyGUID && r.ServiceType == costingRequest.ServiceType && r.Status == "CURRENT") select r).FirstOrDefaultAsync(); if (customerSlab == null) { responseText = "Customer Policy Costing Slab Not Found"; Services.Log.Warn(responseText); return this.Request.CreateResponse(HttpStatusCode.NotFound, responseText); } else { await IncidentController.SaveCostingSlabAsync(costingRequest, customerSlab, "CUSTOMER", Services); responseText = "Incident Costings Request Processed"; infoOutput = new IncidentInfo(costingRequest.IncidentGUID); //Web Client Notifications IHubContext hubContext = Services.GetRealtime<IncidentHub>(); hubContext.Clients.All.updateIncidentCostingAdmin(infoOutput); Services.Log.Info("Connected Clients Generated"); } return this.Request.CreateResponse(HttpStatusCode.OK, responseText); }
public static void SendIncidentPaymentReceiptEmail(Payment payment, ApiServices Services) { SendGridMessage receiptMessage = new SendGridMessage(); IncidentInfo receiptIncident = new IncidentInfo(payment.IncidentGUID); receiptMessage.From = SendGridHelper.GetAppFrom(); receiptMessage.AddTo(receiptIncident.IncidentUserInfo.Email); receiptMessage.Html = " "; receiptMessage.Text = " "; receiptMessage.Subject = " "; receiptMessage.EnableTemplateEngine(WebConfigurationManager.AppSettings["RZ_ReceiptTemplateID"]); receiptMessage.AddSubstitution("%invoicestub%", new List<string> { receiptIncident.IncidentGUID.Substring(0, 5).ToUpper() }); receiptMessage.AddSubstitution("%name%", new List<string> { receiptIncident.IncidentUserInfo.Name }); receiptMessage.AddSubstitution("%jobdescription%", new List<string> { receiptIncident.JobCode }); receiptMessage.AddSubstitution("%servicefee%", new List<string> { receiptIncident.ServiceFee.ToString() }); receiptMessage.AddSubstitution("%datesubmitted%", new List<string> { DateTime.Now.ToShortDateString() }); receiptMessage.AddSubstitution("%paymentmethod%", new List<string> { receiptIncident.PaymentMethod }); receiptMessage.AddSubstitution("%paymentamount%", new List<string> { receiptIncident.PaymentAmount.ToString() }); // Create an Web transport for sending email. var transportWeb = new Web(SendGridHelper.GetNetCreds()); // Send the email. try { transportWeb.Deliver(receiptMessage); Services.Log.Info("Payment Receipt Email Sent to [" + receiptIncident.IncidentUserInfo.Email + "]"); } catch (InvalidApiRequestException ex) { for (int i = 0; i < ex.Errors.Length; i++) { Services.Log.Error(ex.Errors[i]); } } }
public static void SendIncidentSubmissionAdminEmail(Incident incident, ApiServices Services) { SendGridMessage submissionMessage = new SendGridMessage(); IncidentInfo submisionIncident = new IncidentInfo(incident); submissionMessage.From = SendGridHelper.GetAppFrom(); submissionMessage.AddTo(WebConfigurationManager.AppSettings["RZ_SysAdminEmail"]); submissionMessage.Html = " "; submissionMessage.Text = " "; submissionMessage.Subject = " [" + WebConfigurationManager.AppSettings["MS_MobileServiceName"] + "]"; submissionMessage.EnableTemplateEngine(WebConfigurationManager.AppSettings["RZ_SubmisionTemplateID"]); submissionMessage.AddSubstitution("%timestamp%", new List<string> { submisionIncident.CreatedAt.ToString() }); submissionMessage.AddSubstitution("%incidentguid%", new List<string> { submisionIncident.IncidentGUID }); submissionMessage.AddSubstitution("%vehicledetails%", new List<string> { submisionIncident.IncidentVehicleInfo.RegistrationNumber }); submissionMessage.AddSubstitution("%name%", new List<string> { submisionIncident.IncidentUserInfo.Name }); submissionMessage.AddSubstitution("%phone%", new List<string> { submisionIncident.IncidentUserInfo.Phone }); submissionMessage.AddSubstitution("%email%", new List<string> { submisionIncident.IncidentUserInfo.Email }); submissionMessage.AddSubstitution("%jobdescription%", new List<string> { submisionIncident.JobCode }); submissionMessage.AddSubstitution("%location%", new List<string> { submisionIncident.LocationObj.RGDisplay }); // Create an Web transport for sending email. var transportWeb = new Web(SendGridHelper.GetNetCreds()); // Send the email. try { transportWeb.Deliver(submissionMessage); Services.Log.Info("New Incident Submission Email Sent to [" + submisionIncident.IncidentUserInfo.Email + "]"); } catch (InvalidApiRequestException ex) { for (int i = 0; i < ex.Errors.Length; i++) { Services.Log.Error(ex.Errors[i]); } } }