Example #1
0
        public IActionResult EventsDayView(DateDto dto, string ext)
        {
            var dateTime = dto.GetDateTime();

            if (string.IsNullOrEmpty(dto.Name) && dateTime.Year > 2015)
            {
                return(BadRequest("name or date wrong"));
            }

            var result =
                _updateStatusContent.EventsDayView(dateTime, dto.Name);

            if (result == null)
            {
                return(BadRequest("name error"));
            }

            switch (ext)
            {
            case "csv":
                var resultCsv = "DateTime;Weight;Label\n";
                foreach (var item in result.AmountOfMotions)
                {
                    resultCsv += $"{item.StartDateTime};{item.Weight};{item.Label}\n";
                }
                return(Content(resultCsv));

            case "json":
                return(Json(result));

            default:
                return(Json(result));
            }
        }