Esempio n. 1
0
        // Получить клиентов (всех или с фильтром по городу)
        public IActionResult Index(int?CityID)
        {
            IEnumerable <City> CitiesList = WebActions.GetCities().Result;

            ViewData["Cities"] = new SelectList(CitiesList, "Id", "Name");

            if (!CityID.HasValue)
            {
                var Model = WebActions.GetClients().Result;
                ViewData["HeaderPage"] = "Клиенты";

                return(View(Model));
            }
            else
            {
                var Model = WebActions.GetClientsFromCity(CityID).Result;

                if (Model.Count() != 0)
                {
                    ViewData["HeaderPage"] = $"Клиенты из города {Model.ElementAtOrDefault(0).City}";
                    return(View(Model));
                }
                else
                {
                    return(NotFound($"Клиенты из города {CitiesList.FirstOrDefault(c => c.Id == CityID).Name} не найдены."));
                }
            }
        }
Esempio n. 2
0
 // Получить определённого клиента
 public IActionResult EditClient(int?ClientID)
 {
     if (ClientID.HasValue)
     {
         var Model = WebActions.GetClient(ClientID);
         IEnumerable <City> CitiesList = WebActions.GetCities().Result;
         ViewData["Cities"] = new SelectList(CitiesList, "Id", "Name");
         return(View("ClientView", Model.Result));
     }
     else
     {
         IEnumerable <City> CitiesList = WebActions.GetCities().Result;
         ViewData["Cities"] = new SelectList(CitiesList, "Id", "Name");
         ClientView NewClient = new ClientView();
         return(View("ClientView", NewClient));
     }
 }