public int AddProduct(Domain.Product product) { using (var db = CreateDbContext()) { var parameterId = new ObjectParameter("Id", typeof(int)); db.usp_AddProduct( product.Code, product.Name, product.Description, product.Cost, product.ListPrice, product.CategoryId, product.SupplierId, product.ReleaseDate, parameterId); return((int)parameterId.Value); } }
public int AddProduct(Domain.Product product) { var productRecord = new Product { CategoryId = product.CategoryId, Code = product.Code, Cost = product.Cost, CreatedOn = _timeService.Now, Description = product.Description, ListPrice = product.ListPrice, Name = product.Name, ReleaseDate = product.ReleaseDate, SupplierId = product.SupplierId }; using (var db = CreateDbContext()) { db.Products.Add(productRecord); db.SaveChanges(); } return(productRecord.Id); }