public int Insert_ReturnItems(UnOrderedItem item)
        {
            using (var context = new eRaceContext())
            {
                context.UnOrderedItems.Add(item);
                context.SaveChanges();

                return(item.ItemID);
            }
        }
Ejemplo n.º 2
0
        public void AddUnorderedItem(UnorderedInfo item)
        {
            using (var context = new eRaceContext())
            {
                var newItem = new UnOrderedItem
                {
                    ItemName        = item.ItemName,
                    VendorProductID = item.VendorID,
                    Quantity        = item.Quantity
                };

                context.UnOrderedItems.Add(newItem);
                context.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        public int UnOrderedItem_Add(UnOrderedItem item)
        {
            using (var context = new RaceContext())
            {
                if (string.IsNullOrEmpty(item.ItemName))
                {
                    throw new BusinessRuleException("Please enter an unordered item.", reasons);
                }
                else if (item.Quantity <= 0)
                {
                    throw new BusinessRuleException("The Unordered item quantity must be greater than 0", reasons);
                }
                else
                {
                    var exists = (from x in context.Products
                                  where x.ItemName == item.ItemName
                                  select x.ProductID).FirstOrDefault().ToString();


                    item.VendorProductID = exists;

                    item.OrderID = 999;

                    if (item.VendorProductID == null || int.Parse(item.VendorProductID) == 0)
                    {
                        throw new BusinessRuleException("Item does not exist in the database.", reasons);
                    }
                    else
                    {
                        context.UnOrderedItems.Add(item); //staging
                        context.SaveChanges();            //actual commit to the database
                        return(item.ItemID);
                    }
                }
            }
        }
 public int UnorderedItem_Delete(UnOrderedItem item)
 {
     return(UnorderedItem_Delete(item.ItemID));
 }