public List<Product> PostArray(ODataActionParameters parameters) { var productDtos = parameters["products"] as IEnumerable<ProductDto>; var newProducts = new List<Product>(); if (productDtos != null && productDtos.Any()) { foreach (var productDto in productDtos) { var product = new Product { Id = Data.Values.Max(existingProduct => existingProduct.Id) + 1, Name = productDto.Name, Price = productDto.Price, EnumValue = productDto.EnumValue }; newProducts.Add(product); Data.TryAdd(product.Id, product); } } return newProducts; }
public IHttpActionResult Create(ODataActionParameters parameters) { var product = new Product { Id = Data.Values.Max(existingProduct => existingProduct.Id) + 1, Name = (string)parameters["name"], Price = (double)parameters["price"], EnumValue = (MyEnum)parameters["enumValue"] }; Data.TryAdd(product.Id, product); return Created(product); }