예제 #1
0
 public FrontierAg.Models.Shipping GetItem3([FriendlyUrlSegmentsAttribute(2)] int ShippingId)
 {
     using (FrontierAg.Models.ProductContext _db = new FrontierAg.Models.ProductContext())
     {
         return(_db.Shippings.Where(m => m.ShippingId == ShippingId).FirstOrDefault());
     }
 }
예제 #2
0
        public IQueryable <Category> GetCategories()
        {
            var _db = new FrontierAg.Models.ProductContext();
            IQueryable <Category> query = _db.Categories;

            return(query);
        }
예제 #3
0
 public FrontierAg.Models.Contact GetItem([FriendlyUrlSegmentsAttribute(0)] int ContactId)
 {
     using (FrontierAg.Models.ProductContext _db = new FrontierAg.Models.ProductContext())
     {
         return(_db.Contacts.Where(m => m.ContactId == ContactId).FirstOrDefault());
     }
 }
예제 #4
0
 public IQueryable <Order> OrdersList_GetData([FriendlyUrlSegmentsAttribute(0)] int?ContactId)
 {
     if (ContactId != null)
     {
         FrontierAg.Models.ProductContext _db = new FrontierAg.Models.ProductContext();
         return(_db.Orders.Include(m => m.OrderShippings.Select(en => en.Shipping)).Where(en => en.ContactId == ContactId));
     }
     return(null);
 }
예제 #5
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.PackCharge> PackchargeGrid_GetData([FriendlyUrlSegmentsAttribute(0)] int?productId)
        {
            var _db = new FrontierAg.Models.ProductContext();
            IQueryable <PackCharge> query = _db.PackCharges;

            if (productId.HasValue && productId > 0)
            {
                query = query.Where(p => p.ProductId == productId);
            }
            else
            {
                query = null;
            }
            return(query);
        }
예제 #6
0
        public void addPriceForm_InsertItem()
        {
            var item = new FrontierAg.Models.Price();

            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                // Save changes here
                using (FrontierAg.Models.ProductContext db = new FrontierAg.Models.ProductContext())
                {
                    db.Prices.Add(item);
                    db.SaveChanges();
                }
            }
        }
예제 #7
0
        public void addProductForm_InsertItem()
        {
            var item = new FrontierAg.Models.Product();

            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                // Save changes here
                using (FrontierAg.Models.ProductContext db = new FrontierAg.Models.ProductContext())
                {
                    item.DateCreated = DateTime.Now;
                    db.Products.Add(item);
                    db.SaveChanges();
                }
            }
        }
예제 #8
0
        public IQueryable <Product> GetProducts([FriendlyUrlSegmentsAttribute(0)] int?categoryId, [FriendlyUrlSegmentsAttribute(1)] String searchString)
        {
            var _db = new FrontierAg.Models.ProductContext();
            IQueryable <Product> query = _db.Products;

            if (categoryId.HasValue && categoryId > 0)
            {
                return(query = query.Where(p => p.CategoryId == categoryId));
            }
            else if (!String.IsNullOrEmpty(searchString))
            {
                return(query = query.Where(s => s.ProductNo.Contains(searchString) || s.ProductName.Contains(searchString)));
            }

            return(query);
        }