public IActionResult GetChart(int id) { var chart = _chartRepository.GetChart(id); if (chart == null) { return(NotFound()); } var result = Mapper.Map <ChartDto>(chart); return(Ok(result)); }
public async Task <ActionResult <Chart> > GetChart(string id) { try { var result = await chartRepository.GetChart(id); if (result == null) { return(NotFound()); } return(result); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Error retrieving data from teh database.")); } }
public async Task <ActionResult <ChartVM> > GetChart(int id) { try { var result = await chartRepository.GetChart(id); if (result == null) { return(NotFound()); } return(result); } catch (DbUpdateException Ex) { return(StatusCode(StatusCodes.Status500InternalServerError, Ex.InnerException.Message)); } }
public HttpResponseMessage GetChart(int id) { if (loggedUserId == null) { //TODO: you are not logged message here return(Request.CreateResponse(HttpStatusCode.Unauthorized, "err niezalogowany")); } var chart = _chartRepository.GetChart(id).FirstOrDefault(); if (chart == null) { return(Request.CreateResponse(HttpStatusCode.OK, "err chart nie istenieje")); } if (chart.UserId != loggedUserId) { return(Request.CreateResponse(HttpStatusCode.OK, "err nie twoj chart")); } var result = new ChartVm(chart); return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public IActionResult Detail(int id) { var chart = _repository.GetChart(id); return(View(chart)); }