Exemplo n.º 1
0
        public async Task <IActionResult> GetById(int id)
        {
            try
            {
                var model = await _carBrandService.GetAsync(id);

                return(Ok(model));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                var carBrand = await _carBrandService.GetAsync(id);

                if (carBrand != null)
                {
                    await _carBrandService.DeleteAsync(carBrand);
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View("Error", ex));
            }
        }