예제 #1
0
        public void Start(CommandLineParserOptions options)
        {
            if (!(options.Yesterday || (options.BeginDate.HasValue && options.EndDate.HasValue)))
            {
                throw new ArgumentException("Invalid date arguments are provided.");
            }
            else if (!(options.Email))
            {
                throw new ArgumentException("Invalid output arguments are provided.");
            }
            IEnumerable <Stat> stats = null;

            if (options.Yesterday)
            {
                stats = statservice.GetBetween(DateTime.Today.AddDays(-1), DateTime.Today);
            }
            else
            {
                if (options.BeginDate.Value.Date == options.EndDate.Value.Date)
                {
                    throw new Exception("Dates are the same");
                }
                stats = statservice.GetBetween(options.BeginDate.Value.Date, options.EndDate.Value.Date);
            }

            if (stats == null)
            {
                throw new Exception("Stats are null, talk with developers");
            }

            statsExportService.Export(stats);
        }
예제 #2
0
 public IActionResult Post([FromBody] StatByDate statbydate)
 {
     try
     {
         var stats = _statsService.GetBetween(statbydate.From, statbydate.To);
         return(Ok(stats));
     }
     catch (Exception ex)
     {
         var exc = ex.InnerException ?? ex;
         return(StatusCode((int)HttpStatusCode.InternalServerError, exc));
     }
 }