Exemple #1
0
        private async Task GetSelected()
        {
            ViewBag.CarBrands = new SelectList(await _carBrandService.GetAllAsync(), "Id", "Name");
            ViewBag.CarModels = new SelectList(await _carModelService.GetAllAsync(), "Id", "Name");

            var owners = await _ownerService.GetAllAsync();

            ViewBag.Owners = new SelectList(owners.Select(o =>
                                                          new { o.Id,
                                                                Name = $"{ o.FirstName } { o.LastName } { o.Patronymic }" }), "Id", "Name");
        }
        public async Task <IActionResult> GetAll()
        {
            try
            {
                var model = await _carBrandService.GetAllAsync();

                return(Ok(model));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemple #3
0
        public async Task <IActionResult> Index()
        {
            try
            {
                var model = await _carBrandService.GetAllAsync();

                return(View(model));
            }
            catch (Exception ex)
            {
                return(View("Error", ex));
            }
        }
        public async Task <ActionResult <List <CarBrandModel> > > GetAll()
        {
            var result = await _carBrandService.GetAllAsync();

            return(result);
        }