예제 #1
0
        public async Task <IActionResult> Monthly([FromRoute] string symbol,
                                                  [FromRoute] int year, [FromRoute, Range(1, 12)] int month)
        {
            if (!IsMonthValid(month))
            {
                return(BadRequest());
            }

            var price = await _analyticsService.GetMonthlyAsync(symbol, year, month);

            if (price == null)
            {
                return(NotFound());
            }

            var result = new MonthlyModel()
            {
                Symbol = symbol,
                Year   = year,
                Month  = month,
                Price  = Map(price)
            };

            return(Ok(result));
        }
예제 #2
0
        public async Task <IActionResult> Monthly([FromRoute] string symbol, [FromRoute] int year, [FromRoute] int month)
        {
            var result = new MonthlyModel()
            {
                Symbol = symbol,
                Year   = year,
                Month  = month,
                Price  = Map(await _analyticsService.GetMonthlyAsync(symbol, year, month))
            };

            return(Ok(result));
        }
        public async Task <IActionResult> Monthly([FromRoute] string symbol, [FromRoute] int year, [FromRoute] int month)
        {
            // TODO: Add implementation for the monthly summary
            var result = new MonthlyModel()
            {
                Symbol = symbol,
                Year   = year,
                Month  = month,
                Price  = Map(new AnalyticsPrice())
            };

            return(Ok(result));
        }
        public async Task <IActionResult> Monthly([FromRoute] string symbol, [FromRoute] int year, [FromRoute] int month)
        {
            // TODO: Add implementation for the monthly summary

            //validate route values
            if (symbol.Length > 3 || symbol.Length < 3)
            {
                return(BadRequest("Symbol characters exceeded or below"));
            }

            if (year < 1000)
            {
                return(BadRequest("The year value is less"));
            }

            if (!Enumerable.Range(1, 12).Contains(month))
            {
                return(BadRequest("Incorrect month Value"));
            }

            AnalyticsPrice analyticsPrice = new AnalyticsPrice();

            try
            {
                analyticsPrice = await _analyticsService.GetMonthlyAsync(symbol, year, month);
            }
            catch (Exception e)
            {
                return(NotFound(e.Message));
            }
            var result = new MonthlyModel()
            {
                Symbol = symbol,
                Year   = year,
                Month  = month,
                Price  = Map(analyticsPrice)
            };

            return(Ok(result));
        }
예제 #5
0
 public MonthlyDetail(MonthlyModel model)
 {
     InitializeComponent();
     this.DataContext = model;
 }