private XDocument ProcessNotificationRequestsAndGetResponse(List <PaymentNotificationRequestHelper> pnrequests) { BettingSuiteDataContext db = new BettingSuiteDataContext(); List <PaymentNotificationResponse> pnresponses = new List <PaymentNotificationResponse>(pnrequests.Count()); // List<PaymentNotificationResponse> invalidpnresponses = new List<PaymentNotificationResponse>(pnrequests.Count()); foreach (PaymentNotificationRequestHelper pnr in pnrequests) { int refr = int.Parse(pnr.getCustReference().Substring(1)); customer customer = null; //check Type of customer if (pnr.getCustReference().StartsWith(ConfigurationManager.AppSettings["AGENT PREFIX"])) { shop shop = db.shops.SingleOrDefault(a => a.id == refr); if (shop != null) { customer = new customer(shop); if (customer.getReference() != refr) { customer = null; } } else { customer = null; } if (customer != null) { // customer.setPaymentItem(cvr.getPaymentItemCode()); PaymentNotificationResponse pr = new PaymentNotificationResponse(customer, pnr); pr.setStatus(0); savePaymentDetails(pnr); pr.setPaymentLogId(pnr.getPaymentLogId().ToString()); pnresponses.Add(pr); } else { customer = new customer(null, null, null, null, null, null, 1); customer.setReference(refr); PaymentNotificationResponse ipr = new PaymentNotificationResponse(customer, pnr); ipr.setStatus(1); pnresponses.Add(ipr); } } else if (pnr.getCustReference().StartsWith(ConfigurationManager.AppSettings["ONLINE USER PREFIX"])) { // SORT OUT ONLINE LATER } else { customer = new customer(null, null, null, null, null, null, 1); customer.setReference(refr); PaymentNotificationResponse ipr = new PaymentNotificationResponse(customer, pnr); ipr.setStatus(1); pnresponses.Add(ipr); } } return(generatePaymentNotificationResponse(pnresponses)); }