コード例 #1
0
        private async Task <Customer> UpdateCustomer(PendingBooking pendingBooking)
        {
            var customer = await _repo.GetCustomerById(pendingBooking.CustomerId);

            customer.FirstName = pendingBooking.CustomerFirstName;
            customer.LastName  = pendingBooking.CustomerLastName;
            customer.Title     = pendingBooking.CustomerTitle;

            if (customer.Address == null)
            {
                customer.Address = new Address();
            }

            customer.Address.AddressLine1 = pendingBooking.CustomerAddressLine1;
            customer.Address.AddressLine2 = pendingBooking.CustomerAddressLine2;
            customer.Address.AddressLine3 = pendingBooking.CustomerAddressLine3;
            customer.Address.Postcode     = pendingBooking.CustomerPostcode;
            customer.Address.Country      = pendingBooking.CustomerCountry;
            customer.Address.ModifiedBy   = pendingBooking.CreatedBy;
            customer.Address.ModifiedDate = DateTime.Now;
            customer.LandLine             = pendingBooking.CustomerLandline;
            customer.MobileNo             = pendingBooking.CustomerMobile;
            customer.ModifiedDate         = DateTime.Now;
            customer.ModifiedBy           = pendingBooking.CreatedBy;

            return(customer);
        }
コード例 #2
0
        public async Task <IActionResult> GetCustomerById(int id)
        {
            Customer customer = await _repo.GetCustomerById(id);

            if (customer == null)
            {
                return(BadRequest());
            }

            var customerToReturn = _mapper.Map <CustomerDto>(customer);

            return(Ok(customerToReturn));
        }