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

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

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