public IActionResult GetById(int id) { var Sale = service.FindById(id); if (Sale == null) { return(NotFound()); } return(Ok(Sale)); }
// GET: SalesController/Details/5 public ActionResult Details(int id) { Sale sale = _saleService.FindById(id); if (sale == null) { return(RedirectToAction(nameof(Index))); } return(View(sale)); }
public JsonResult GetById([FromRoute] int id) { try { var result = _service.FindById(id); if (result != null) { return(new JsonResult(result)); } return(new JsonResult($"Not found: {id}") { StatusCode = 404 }); } catch (Exception e) { return(new JsonResult(e) { StatusCode = 500 }); } }
// GET: Sale/Details/5 public ActionResult Details(int id) { return(View(_mapper.Map <SaleDTO, SaleViewModel>(_saleService.FindById(id)))); }