Ejemplo n.º 1
0
        public async Task <IActionResult> SearchAirlines(AirlineSearchParameters param)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new { Message = "Invalid search parameters supplied" }));
            }
            var ret = await service.GetAirlines(param);

            var temp = mapper.Map <IEnumerable <AirlineResource> >(ret);

            foreach (var a in temp)
            {
                var b = ret.First(i => i.Id == a.Id);
                if (b.Ratings.Count > 0)
                {
                    a.Rating = b.Ratings.Sum(i => i.Rate) / b.Ratings.Count;
                }
                else
                {
                    a.Rating = 0;
                }
            }
            return(Ok(new { Airlines = temp }));
        }
Ejemplo n.º 2
0
        // GET: Airline
        public ActionResult Index()
        {
            var models = _airlineService.GetAirlines();

            return(View(models));
        }