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."));
            }
        }
Пример #3
0
        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));
            }
        }
Пример #4
0
        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));
        }