//
        // GET: Customers/Create
        /// <summary>
        /// The create customer page.
        /// </summary>
        public async Task <ActionResult> Create()
        {
            var viewModel = new CustomerFormViewModel("Create");
            await viewModel.PopulateLocationsAsync(this.context);

            viewModel.TelephoneNumbers = new List <TelephoneNumber>();

            return(this.View(viewModel));
        }
        //
        // GET: Customers/Edit/5
        /// <summary>
        /// The edit customer view.
        /// </summary>
        /// <param name="id">The identifier.</param>
        public async Task <ActionResult> Edit(long id)
        {
            // Validate identifier
            if (id <= 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            // Retrieve customer
            var customer = this.context.Customers.FirstOrDefault(c => c.Id == id);

            if (customer == null)
            {
                return(this.HttpNotFound());
            }

            // Populate view model
            var vm = new CustomerFormViewModel("Edit")
            {
                TelephoneNumbers   = customer.TelephoneNumbers,
                Name               = customer.Name,
                Address            = customer.Address,
                AddressId          = customer.AddressId,
                CreationDate       = customer.CreationDate,
                CustomerCountryId  = customer.Address.Place?.CountryId,
                CustomerDevices    = customer.CustomerDevices,
                CustomerPlaceId    = customer.Address.PlaceId,
                CustomerPlaceName  = customer.Address.Place?.Name,
                CustomerStreetName = customer.Address.StreetAddress,
                Email              = customer.Email,
                Id        = customer.Id,
                Note      = customer.Note,
                WorkItems = customer.WorkItems
            };
            await vm.PopulateLocationsAsync(this.context);

            // Return the edit view
            return(this.View(vm));
        }