public async Task <HttpResponseMessage> Post(LibBookingService.Dtos.Customer customer)
        {
            try
            {
                Customer newCustomer = _db.Customers.Add(new Customer
                {
                    OwinUserId        = customer.OwinUserId,
                    UserName          = customer.UserName,
                    Title             = customer.Title,
                    Forename          = customer.Forename,
                    Surname           = customer.Surname,
                    Dob               = customer.DoB,
                    AddressStreet     = customer.AddressStreet,
                    AddressTown       = customer.AddressTown,
                    AddressCounty     = customer.AddressCounty,
                    AddressPostalCode = customer.AddressPostalCode,
                    HomePhoneNo       = customer.HomePhoneNo,
                    WorkPhoneNo       = customer.WorkPhoneNo,
                    MobilePhoneNo     = customer.MobilePhoneNo,
                    Email             = customer.Email
                });
                await _db.SaveChangesAsync();

                return(Request.CreateResponse(HttpStatusCode.OK, CreateCustomerFromDbCustomer(newCustomer)));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Failed"));
            }
        }
        public async Task <HttpResponseMessage> Update(int id, LibBookingService.Dtos.Customer customer)
        {
            try
            {
                Customer c = await _db.Customers.Where(m => m.Id == id).FirstOrDefaultAsync();

                c.OwinUserId        = customer.OwinUserId;
                c.UserName          = customer.UserName;
                c.Title             = customer.Title;
                c.Forename          = customer.Forename;
                c.Surname           = customer.Surname;
                c.Dob               = customer.DoB;
                c.AddressStreet     = customer.AddressStreet;
                c.AddressTown       = customer.AddressTown;
                c.AddressCounty     = customer.AddressCounty;
                c.AddressPostalCode = customer.AddressPostalCode;
                c.HomePhoneNo       = customer.HomePhoneNo;
                c.WorkPhoneNo       = customer.WorkPhoneNo;
                c.MobilePhoneNo     = customer.MobilePhoneNo;
                c.Email             = customer.Email;

                _db.SetModified(c);
                await _db.SaveChangesAsync();

                LibBookingService.Dtos.Customer res = CreateCustomerFromDbCustomer(c);

                return(Request.CreateResponse(HttpStatusCode.OK, res));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Failed"));
            }
        }
        public async Task <HttpResponseMessage> GetByAuth(Customer customer)
        {
            Customer res = await _db.Customers.Where(c => !c.Deleted && c.UserName == customer.UserName && c.OwinUserId == customer.OwinUserId).FirstOrDefaultAsync();

            if (res == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NoContent, "No Customer Found With ID"));
            }

            LibBookingService.Dtos.Customer cust = CreateCustomerFromDbCustomer(res);

            return(Request.CreateResponse(HttpStatusCode.OK, cust));
        }
        public async Task <HttpResponseMessage> Get(int id = -1)
        {
            Customer res = await _db.Customers.Where(c => c.Id == id && !c.Deleted).FirstOrDefaultAsync();

            if (res == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NoContent, "No Customer Found With ID"));
            }

            LibBookingService.Dtos.Customer customer = CreateCustomerFromDbCustomer(res);

            return(Request.CreateResponse(HttpStatusCode.OK, customer));
        }