Exemplo n.º 1
0
        public void UpdateItem(int OrderID, int updateProductID, int qtyShipped, int qtyCancelled, string comment)
        {
            using (var _db = new FrontierAg.Models.ProductContext())
            {
                try
                {
                    var myDBOrderDetail = (from c in _db.OrderDetails where c.OrderId == OrderID && c.ProductId == updateProductID select c).FirstOrDefault();

                    if (myDBOrderDetail != null)
                    {
                        //do the work.............
                        if (qtyCancelled + qtyShipped <= myDBOrderDetail.Quantity)
                        {
                            myDBOrderDetail.QtyShipped   = qtyShipped;
                            myDBOrderDetail.QtyCancelled = qtyCancelled;
                            myDBOrderDetail.Comment      = comment;
                        }

                        _db.SaveChanges();
                    }
                }
                catch (Exception exp)
                {
                    throw new Exception("ERROR: Unable to Update Cart Item - " + exp.Message.ToString(), exp);
                }
            }
        }
Exemplo n.º 2
0
        // The return type can be changed to IEnumerable, however to support
        // paging and sorting, the following parameters must be added:
        //     int maximumRows
        //     int startRowIndex
        //     out int totalRowCount
        //     string sortByExpression
        public IQueryable <FrontierAg.Models.OrderDetail> AllDetailsGrid_GetData()
        {
            IList <string> segments = Request.GetFriendlyUrlSegments();

            ContactId = int.Parse(segments[0]);

            if (ContactId != null)
            {
                FrontierAg.Models.ProductContext _db = new FrontierAg.Models.ProductContext();
                //var my = from r in _db.OrderDetails
                return(_db.OrderDetails.Where(mn => mn.Order.ContactId == ContactId));
            }
            return(null);
        }
Exemplo n.º 3
0
 public void RemoveItem(string removeCartID, int removeProductID)
 {
     using (var _db = new FrontierAg.Models.ProductContext())
     {
         try
         {
             var myItem = (from c in _db.ShoppingCartItems where c.CartId == removeCartID && c.Product.ProductId == removeProductID select c).FirstOrDefault();
             if (myItem != null)
             {
                 // Remove Item.
                 _db.ShoppingCartItems.Remove(myItem);
                 _db.SaveChanges();
             }
         }
         catch (Exception exp)
         {
             throw new Exception("ERROR: Unable to Remove Cart Item - " + exp.Message.ToString(), exp);
         }
     }
 }
Exemplo n.º 4
0
        public void UpdateItem(string updateCartID, int updateProductID, int quantity, Decimal PriceOverride) // execute when changing price box or qty
        {
            using (var _db = new FrontierAg.Models.ProductContext())
            {
                //try
                //{
                //get item from CartItem Table in DB
                var myItem = (from c in _db.ShoppingCartItems where c.CartId == updateCartID && c.Product.ProductId == updateProductID select c).FirstOrDefault();


                if (myItem != null)
                {
                    //if QTY changed, get price from table
                    if (myItem.Quantity != quantity)
                    {
                        myItem.Quantity      = quantity;
                        myItem.ItemPrice     = GetPriceFromPrices(updateProductID, quantity);
                        myItem.Charge        = GetChargeFromPackCharges(updateProductID, quantity);
                        myItem.OriginalPrice = myItem.ItemPrice;
                    }
                    else
                    {
                        //if Price changed, then use new price
                        myItem.ItemPrice = PriceOverride;
                    }

                    CartSessionFlag = 0;
                    _db.SaveChanges();
                }
                else
                {
                    CartSessionFlag = updateProductID;
                }

                //}
                //catch (Exception exp)
                //{
                //    throw new Exception("ERROR: Unable to Update Cart Item - " + exp.Message.ToString(), exp);
                //}
            }
        }