public bool updateItem(string itemNo, string category, string description, int reorderLevel, int reorderQty, string unitOfMeasurement, int balance) { try { var cat = from c in ctx.Categories where c.CategoryName == category select c; ADTeam4EF.Category cate = cat.First(); var item = from i in ctx.Items where i.ItemID == itemNo select i; ADTeam4EF.Item it = item.First(); if (item != null) { using (TransactionScope ts = new TransactionScope()) { it.Description = description; it.ReorderLevel = reorderLevel; it.ReorderQuantity = reorderQty; it.UnitOfMeasurement = unitOfMeasurement; it.Balance = balance; it.CategoryID = cate.CategoryID; ctx.SaveChanges(); ts.Complete(); return(true); } } else { return(false); } } catch (Exception ex) { return(false); throw ex; } }
public bool checkCategory(string category) { try { var cat = from c in ctx.Categories where c.CategoryName == category select c; ADTeam4EF.Category cate = cat.FirstOrDefault(); if (cate != null) { return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }