コード例 #1
0
 public ActionResult <IEnumerable <Consumo> > Get()
 {
     return(Ok(new
     {
         status = "200",
         msg = "OK",
         obj = repository.GetAll()
     }));
 }
コード例 #2
0
        public IActionResult Get()
        {
            var sugestao = _consumoRepository.GetAll()
                           .GroupBy(x => x.RestauranteId)
                           .Select(sl => new
            {
                Restaurante = sl.First().Restaurante.Nome,
                Valor       = sl.Sum(s => s.Valor) / sl.Count()
            }).OrderBy(x => x.Valor).FirstOrDefault();

            if (sugestao == null)
            {
                return(ResponseError("Não existem consumos cadastrados"));
            }

            return(ResponseOk(new SugestaoViewModel
            {
                Restaurante = sugestao.Restaurante,
                Valor = sugestao.Valor
            }));
        }
コード例 #3
0
        public IActionResult Index()
        {
            var sugestao = _consumoRepository.GetAll()
                           .GroupBy(x => x.RestauranteId)
                           .Select(sl => new
            {
                Restaurante = sl.First().Restaurante.Nome,
                Valor       = sl.Sum(s => s.Valor) / sl.Count()
            }).OrderBy(x => x.Valor).FirstOrDefault();

            if (sugestao == null)
            {
                return(View());
            }

            return(View(new SugestaoViewModel
            {
                Restaurante = sugestao.Restaurante,
                Valor = sugestao.Valor
            }));
        }
コード例 #4
0
 public IActionResult View(int id)
 {
     ViewBag.Consumos = consumoRepository.GetAll();
     return(View(restauranteRepository.GetById(id)));
 }
コード例 #5
0
 public IActionResult Index()
 {
     ViewBag.menorPreco = consumoRepository.GetMenorPreco();
     ViewBag.maiorPreco = consumoRepository.GetMaiorPreco();
     return(View(consumoRepository.GetAll()));
 }
コード例 #6
0
        public IActionResult Index()
        {
            var consumos = _mapper.Map <IEnumerable <ConsumoViewModel> >(_consumoRepository.GetAll());

            return(View(consumos));
        }
コード例 #7
0
 public IActionResult Index()
 {
     return(View(consumoRepository.GetAll()));
 }