public async Task <IActionResult> Edit(int id, ClientCUViewModel client)
        {
            if (id != client.ClientID)
            {
                return(this.NotFound());
            }

            if (this.ModelState.IsValid)
            {
                try
                {
                    await this.clientService.UpdateClientAsync(client.ClientID, client.Name, client.UIN, client.AddressId, client.CityId, client.CountryId);
                }
                catch (Exception ex)
                {
                    this.ModelState.AddModelError("Error", ex.Message);
                }
                return(this.View(client));
            }
            this.ViewData["Addresses"] = new SelectList(await this.addressService.GetAllAddressesAsync(), "AddressID", "Name", client.AddressId);
            this.ViewData["Cities"]    = new SelectList(await this.cityService.GetAllCitiesAsync(), "CityID", "Name", client.CityId);
            this.ViewData["Countries"] = new SelectList(await this.countryService.GetAllCountriesAsync(), "CountryID", "Name", client.CountryId);

            return(this.View(client));
        }
        public async Task <IActionResult> Create(ClientCUViewModel client)
        {
            if (this.ModelState.IsValid)
            {
                await this.clientService.CreateClientAsync(client.Name, client.UIN, client.AddressId, client.CityId, client.CountryId, client.StoreUserId);

                return(this.RedirectToAction(nameof(Index)));
            }
            this.ViewData["Addresses"] = new SelectList(await this.addressService.GetAllAddressesAsync(), "AddressID", "Name", client.AddressId);
            this.ViewData["Cities"]    = new SelectList(await this.cityService.GetAllCitiesAsync(), "CityID", "Name", client.CityId);
            this.ViewData["Countries"] = new SelectList(await this.countryService.GetAllCountriesAsync(), "CountryID", "Name", client.CountryId);
            return(this.View(client));
        }