public async Task <BusinessLogic.Objects.Customer> GetCustomerByID(int CustomerID) { try { return(ParseHandler.ContextCustomerToLogicCustomer(await _context.Customer.AsNoTracking().FirstAsync(c => c.CustomerId == CustomerID))); } catch (Exception e) { throw new Exception("Failed to retrieve customer information for customer ID: " + CustomerID + "\nException thrown: " + e.Message); } }
public BusinessLogic.Objects.Customer GetLastCustomerWithFirstLast(string firstName, string lastName) { try { Customer CTXCust = new Customer(); //Customer CTXCustomer = await _context.Customer.Where(c => c.FirstName == firstName).LastAsync(); foreach (Customer CTXCustomer in _context.Customer.Where(c => c.FirstName == firstName && c.LastName == lastName)) { CTXCust = CTXCustomer; } return(ParseHandler.ContextCustomerToLogicCustomer(CTXCust)); } catch (InvalidOperationException e) { throw new Exception("Failed to get the new customer with first name: " + firstName + "\nand lastName: " + lastName + "\nException: " + e.Message); } }