public async Task<HttpResponseMessage> CreateAsync(ProductAddModel model)
 {
     var product = await Services.Management.CreateProductAsync(model);
     var response = Request.CreateResponse(HttpStatusCode.Created);
     var uri = Url.Link(RetrieveProductRoute, new {id = product.Id});
     response.Headers.Location = new Uri(uri);
     return response;
 }
        public async Task<ProductModel> CreateProductAsync(ProductAddModel model)
        {
            if (await _repositories.Products.AnyAsync(o => o.Name == model.Name))
                throw new BusinessException(string.Format("A product already exists with name: {0}", model.Name));

            var product = new Product(model.Name)
            {
                Description = model.Description,
                QuantityAvailable = model.QuantityAvailable
            };

            _repositories.Products.Insert(product);

            await _repositories.SaveChangesAsync();

            return Mapper.Map<ProductModel>(product);
        }