예제 #1
0
        public async virtual Task <IActionResult> PostMetadataAsync([FromBody] List <TimeseriesMetadata> items)
        {
            try
            {
                if (items == null || items.Count == 0)
                {
                    return(BadRequest($"List of timeseries metadata must be specified"));
                }

                var data = items.Select(i => new TimeseriesMetadata
                {
                    Id          = string.IsNullOrEmpty(i.Id) ? Guid.NewGuid().ToString() : i.Id,
                    Created     = i.Created,
                    Description = i.Description,
                    Name        = i.Name,
                    Source      = i.Source,
                    Units       = i.Units,
                    Updated     = i.Updated
                }).ToList();
                await timeseriesMetadataRepository.CreateManyAsync(data);

                return(Created(this.BuildLink(), data));
            }
            catch (Exception e)
            {
                return(this.InternalServerError(e.FlattenMessages()));
            }
        }