public IEnumerable<ProductViewModel> RetrieveProductByCategory(ProductViewModel item) { int categoryId = item.CategoryId; var records = from products in db.Products where products.CategoryId == categoryId select products; return records; }
public ProductCreationViewModel AssignProductValue(ProductViewModel item) { var productTransfer = new ProductCreationViewModel() { ProductId = item.ProductId, CategoryId = item.CategoryId, Description = item.Description, }; return productTransfer; }
public ProductViewModel Create(ProductViewModel item) { var newRecord = new ProductViewModel { Description = item.Description, Status = "Active", CategoryId = item.CategoryId }; db.Products.Add(newRecord); db.SaveChanges(); return newRecord; }
public ProductViewModel Update(int id, ProductViewModel item) { var currentrecord = db.Products .Where(x => x.ProductId == id) .FirstOrDefault(); if (!(String.IsNullOrWhiteSpace(item.Description))) { currentrecord.Description = item.Description; currentrecord.CategoryId = item.CategoryId; } db.SaveChanges(); return currentrecord; }