public async Task <IActionResult> ClientAddAddress([FromBody] BodyAddressDTO dto)
        {
            var customer = await GetCustomer();

            if (customer == null)
            {
                return(Ok(ResponseDTO.BadRequest("Invalid customers' username.")));
            }

            var newAddress = new Address()
            {
                City                 = dto.city,
                District             = dto.district,
                Ward                 = dto.ward,
                Street               = dto.street,
                CustomerId           = customer.Id,
                RecipientName        = dto.name,
                RecipientPhoneNumber = dto.phoneNumber
            };

            customer.Addresses.Add(newAddress);
            await _context.SaveChangesAsync();

            var listResponse = new List <object>();

            foreach (var add in customer.Addresses)
            {
                listResponse.Add(ConvertToResponseAddressDTO(add, customer.Id));
            }
            return(Ok(ResponseDTO.Ok(listResponse)));
        }
        public async Task <IActionResult> ClientUpdateAddress([FromBody] BodyAddressDTO dto)
        {
            var customer = await GetCustomer();

            if (customer == null)
            {
                return(Ok(ResponseDTO.BadRequest("Invalid customers' username.")));
            }

            var updateAddress = customer.Addresses.FirstOrDefault(c => c.Id == dto.id);

            if (updateAddress != null)
            {
                updateAddress.City                 = dto.city;
                updateAddress.District             = dto.district;
                updateAddress.Ward                 = dto.ward;
                updateAddress.Street               = dto.street;
                updateAddress.CustomerId           = customer.Id;
                updateAddress.RecipientName        = dto.name;
                updateAddress.RecipientPhoneNumber = dto.phoneNumber;
            }
            else
            {
                return(Ok(ResponseDTO.NotFound("Invalid ID for updated address.")));
            }

            await _context.SaveChangesAsync();

            var listResponse = new List <object>();

            foreach (var add in customer.Addresses)
            {
                listResponse.Add(ConvertToResponseAddressDTO(add, customer.Id));
            }
            return(Ok(ResponseDTO.Ok(listResponse)));
        }