public bool Add(ProductModifyModel entity) { using (var repository = _sourceFactory.CreateRepository <Product, int>()) { return(repository.Add(new Product { ProductCode = entity.ProductCode, Name = entity.Name, Price = entity.Price, Description = entity.Description, ProductGroupId = entity.ProductGroupId, })); }; }
public bool Update(int id, ProductModifyModel entity) { using (var repository = _sourceFactory.CreateRepository <Product, int>()) { var product = repository.GetSingle(id); if (product == null) { throw new NotFoundException(); } product.ProductCode = entity.ProductCode; product.Name = entity.Name; product.Price = entity.Price; product.Description = entity.Description; product.ProductGroupId = entity.ProductGroupId; return(repository.Update(product)); } }