// GET: Workshops/Details/5 public ActionResult Details(int id) { Workshops workshops = workshopService.GetWorkshopById(id); WorkshopViewModel model = new WorkshopViewModel(); model.InjectFrom(workshops); return(View(workshops)); }
public ActionResult <WorkshopDto> GetById(int id) { var workshops = service.GetWorkshopById(id); if (workshops != null) { return(Ok(mapper.Map <WorkshopDto>(workshops))); } return(NotFound($"Workshop with ID: {id} was not found")); }
public IActionResult Edit(int?id) { WorkshopDto model = new WorkshopDto(); if (id.HasValue) { var existingWorkshop = service.GetWorkshopById(id.Value); if (existingWorkshop != null) { model = mapper.Map <WorkshopDto>(existingWorkshop); } } return(View(model)); }
public ActionResult <Workshop> GetWorkshopById([FromRoute] int workshopId) { try { return(Ok(_service.GetWorkshopById(workshopId))); } catch (NotFoundItemException ex) { return(StatusCode(StatusCodes.Status404NotFound, $"Something bad happened: {ex.Message}")); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, $"Something bad happened: {ex.Message}")); } }
public IActionResult GetById(int id) { return(Ok(workshopService.GetWorkshopById(id))); }