Ejemplo n.º 1
0
        public AccountDetail GetAccountDetail(int id)
        {
            FarmSaleDBEntities1 db            = new FarmSaleDBEntities1();
            AccountDetail       accountDetail = db.AccountDetails.Where(ad => ad.accountDetailID == id).FirstOrDefault();

            return(accountDetail);
        }
Ejemplo n.º 2
0
        public Order GetOrder(int id)
        {
            FarmSaleDBEntities1 db = new FarmSaleDBEntities1();
            Order order            = db.Orders.Where(o => o.orderID == id).FirstOrDefault();

            return(order);
        }
Ejemplo n.º 3
0
        public Product GetProduct(int id)
        {
            FarmSaleDBEntities1 db      = new FarmSaleDBEntities1();
            Product             product = db.Products.Where(p => p.productID == id).FirstOrDefault();

            return(product);
        }
Ejemplo n.º 4
0
        public Farm GetFarm(int id)
        {
            FarmSaleDBEntities1 db = new FarmSaleDBEntities1();
            Farm farm = db.Farms.Where(f => f.farmID == id).FirstOrDefault();

            return(farm);
        }
Ejemplo n.º 5
0
        public Account GetAccount(int id)
        {
            FarmSaleDBEntities1 db      = new FarmSaleDBEntities1();
            Account             account = db.Accounts.Where(a => a.accountID == id).FirstOrDefault();

            return(account);
        }
Ejemplo n.º 6
0
        public IEnumerable <Product> GetProductsByCategory(string category)
        {
            FarmSaleDBEntities1 db       = new FarmSaleDBEntities1();
            List <Product>      products = db.Products.Where(p => p.productCategory == category).ToList();

            return(products);
        }
Ejemplo n.º 7
0
        public Address GetAddress(int id)
        {
            FarmSaleDBEntities1 db      = new FarmSaleDBEntities1();
            Address             address = db.Addresses.Where(a => a.addressID == id).FirstOrDefault();

            return(address);
        }
Ejemplo n.º 8
0
        public FarmProduct GetFarmProduct(int id)
        {
            FarmSaleDBEntities1 db          = new FarmSaleDBEntities1();
            FarmProduct         farmProduct = db.FarmProducts.Where(fp => fp.farmProductID == id).FirstOrDefault();

            return(farmProduct);
        }
Ejemplo n.º 9
0
        public void RemoveFarm(int id)
        {
            FarmSaleDBEntities1 db = new FarmSaleDBEntities1();
            Farm farm = db.Farms.Where(f => f.farmID == id).FirstOrDefault();

            db.Farms.Remove(farm);
            db.SaveChanges();
        }
Ejemplo n.º 10
0
        public void RemoveAccountDetail(int id)
        {
            FarmSaleDBEntities1 db            = new FarmSaleDBEntities1();
            AccountDetail       accountDetail = db.AccountDetails.Where(ad => ad.accountDetailID == id).FirstOrDefault();

            db.AccountDetails.Remove(accountDetail);
            db.SaveChanges();
        }
Ejemplo n.º 11
0
        public void RemoveAccount(int id)
        {
            FarmSaleDBEntities1 db      = new FarmSaleDBEntities1();
            Account             account = db.Accounts.Where(a => a.accountID == id).FirstOrDefault();

            db.Accounts.Remove(account);
            db.SaveChanges();
        }
Ejemplo n.º 12
0
        public void RemoveProduct(int id)
        {
            FarmSaleDBEntities1 db      = new FarmSaleDBEntities1();
            Product             product = db.Products.Where(p => p.productID == id).FirstOrDefault();

            db.Products.Remove(product);
            db.SaveChanges();
        }
Ejemplo n.º 13
0
        public void RemoveAddress(int id)
        {
            FarmSaleDBEntities1 db      = new FarmSaleDBEntities1();
            Address             address = db.Addresses.Where(a => a.addressID == id).FirstOrDefault();

            db.Addresses.Remove(address);
            db.SaveChanges();
        }
Ejemplo n.º 14
0
        public void RemoveFarmProduct(int id)
        {
            FarmSaleDBEntities1 db          = new FarmSaleDBEntities1();
            FarmProduct         farmProduct = db.FarmProducts.Where(fp => fp.farmProductID == id).FirstOrDefault();

            db.FarmProducts.Remove(farmProduct);
            db.SaveChanges();
        }
Ejemplo n.º 15
0
        public void RemoveOrder(int id)
        {
            FarmSaleDBEntities1 db = new FarmSaleDBEntities1();
            Order order            = db.Orders.Where(o => o.orderID == id).FirstOrDefault();

            db.Orders.Remove(order);
            db.SaveChanges();
        }
Ejemplo n.º 16
0
        public void AddFarmProduct(int farmID, int productID)
        {
            FarmSaleDBEntities1 db          = new FarmSaleDBEntities1();
            FarmProduct         farmProduct = new FarmProduct();

            farmProduct.farmID    = farmID;
            farmProduct.productID = productID;
            db.FarmProducts.Add(farmProduct);
            db.SaveChanges();
        }
Ejemplo n.º 17
0
        public void AddOrder(int accountID, int farmProductID, int qty)
        {
            FarmSaleDBEntities1 db = new FarmSaleDBEntities1();
            Order order            = new Order();

            order.accountID     = accountID;
            order.farmProductID = farmProductID;
            order.qty           = qty;
            db.Orders.Add(order);
            db.SaveChanges();
        }
Ejemplo n.º 18
0
        public void AddAccountDetail(int accountID, int farmID, int addressID)
        {
            FarmSaleDBEntities1 db            = new FarmSaleDBEntities1();
            AccountDetail       accountDetail = new AccountDetail();

            accountDetail.accountID = accountID;
            accountDetail.farmID    = farmID;
            accountDetail.addressID = addressID;
            db.AccountDetails.Add(accountDetail);
            db.SaveChanges();
        }
Ejemplo n.º 19
0
        public void UpdateAccount(int id, string email)
        {
            FarmSaleDBEntities1 db      = new FarmSaleDBEntities1();
            Account             account = db.Accounts.Where(a => a.accountID == id).FirstOrDefault();

            if (account != null)
            {
                account.email = email;
                db.SaveChanges();
            }
        }
Ejemplo n.º 20
0
        public IEnumerable <Product> GetProductsByFarm(int farmID)
        {
            FarmSaleDBEntities1 db           = new FarmSaleDBEntities1();
            List <FarmProduct>  farmProducts = db.FarmProducts.Where(fp => fp.farmID == farmID).ToList();
            List <Product>      products     = new List <Product>();

            foreach (var farmProduct in farmProducts)
            {
                products.Add(db.Products.Where(p => p.productID == farmProduct.productID).FirstOrDefault());
            }
            return(products);
        }
Ejemplo n.º 21
0
        public void AddFarm(string name, string profile)
        {
            FarmSaleDBEntities1 db = new FarmSaleDBEntities1();

            Farm farm = new Farm();

            farm.farmName    = name;
            farm.farmProfile = profile;

            db.Farms.Add(farm);
            db.SaveChanges();
        }
Ejemplo n.º 22
0
        public void UpdateFarm(int id, string name, string profile)
        {
            FarmSaleDBEntities1 db = new FarmSaleDBEntities1();
            Farm farm = db.Farms.Where(f => f.farmID == id).FirstOrDefault();

            if (farm != null)
            {
                farm.farmName    = name;
                farm.farmProfile = profile;
                db.SaveChanges();
            }
        }
Ejemplo n.º 23
0
        public void AddAddress(string streetName, string streetNum, string province, string city, string zip)
        {
            FarmSaleDBEntities1 db      = new FarmSaleDBEntities1();
            Address             address = new Address();

            address.streetName = streetName;
            address.streetNum  = streetNum;
            address.province   = province;
            address.city       = city;
            address.zip        = zip;

            db.Addresses.Add(address);
            db.SaveChanges();
        }
Ejemplo n.º 24
0
        //Need to add encryption to password
        public void AddAccount(string username, string password, string email, string accountType)
        {
            FarmSaleDBEntities1 db = new FarmSaleDBEntities1();

            Account account = new Account();

            account.username    = username;
            account.password    = password;//Add encryption? Do we need this field?
            account.email       = email;
            account.accountType = accountType;

            db.Accounts.Add(account);
            db.SaveChanges();
        }
Ejemplo n.º 25
0
        public void UpdateAddress(int id, string streetName, string streetNum, string province, string city, string zip)
        {
            FarmSaleDBEntities1 db      = new FarmSaleDBEntities1();
            Address             address = db.Addresses.Where(a => a.addressID == id).FirstOrDefault();

            if (address != null)
            {
                address.streetName = streetName;
                address.streetNum  = streetNum;
                address.province   = province;
                address.city       = city;
                address.zip        = zip;
                db.SaveChanges();
            }
        }
Ejemplo n.º 26
0
        public void UpdateProduct(int id, string name, decimal price, string category, string description, int qty)
        {
            FarmSaleDBEntities1 db      = new FarmSaleDBEntities1();
            Product             product = db.Products.Where(p => p.productID == id).FirstOrDefault();

            if (product != null)
            {
                product.productName        = name;
                product.price              = price;
                product.productCategory    = category;
                product.productDescription = description;
                product.qty = qty;
                db.SaveChanges();
            }
        }
Ejemplo n.º 27
0
        public void AddProduct(string name, decimal price, string category, string description, int qty)
        {
            FarmSaleDBEntities1 db = new FarmSaleDBEntities1();

            Product product = new Product();

            product.productName        = name;
            product.price              = price;
            product.productCategory    = category;
            product.productDescription = description;
            product.qty = qty;

            db.Products.Add(product);
            db.SaveChanges();
        }
Ejemplo n.º 28
0
        public ActionResult Add(string productName, decimal price, string productCategory, string productDescription, int qty)
        {
            Product product = new Product();
            product.productName = productName;
            product.price = price;
            product.productCategory = productCategory;
            product.productDescription = productDescription;
            product.qty = qty;

            FarmSaleDBEntities1 db = new FarmSaleDBEntities1();
            db.Products.Add(product);
            db.SaveChanges();

            return RedirectToAction("List");
        }
Ejemplo n.º 29
0
        public ActionResult Add(string productName, decimal price, string productCategory, string productDescription, int qty)
        {
            Product product = new Product();

            product.productName        = productName;
            product.price              = price;
            product.productCategory    = productCategory;
            product.productDescription = productDescription;
            product.qty = qty;

            FarmSaleDBEntities1 db = new FarmSaleDBEntities1();

            db.Products.Add(product);
            db.SaveChanges();

            return(RedirectToAction("List"));
        }
Ejemplo n.º 30
0
        //Users
        public UserProfileVM GetUserProfile(int accountID)
        {
            FarmSaleDBEntities1 db            = new FarmSaleDBEntities1();
            AccountDetail       accountDetail = db.AccountDetails.Where(ad => ad.accountID == accountID).FirstOrDefault();
            Account             account       = db.Accounts.Where(a => a.accountID == accountID).FirstOrDefault();
            Address             address       = db.Addresses.Where(adr => adr.addressID == accountDetail.addressID).FirstOrDefault();
            UserProfileVM       profile       = new UserProfileVM();

            profile.Username   = account.username;
            profile.Email      = account.email;
            profile.StreetNum  = address.streetNum;
            profile.StreetName = address.streetName;
            profile.Province   = address.province;
            profile.City       = address.city;
            profile.Zip        = address.zip;
            return(profile);
        }
Ejemplo n.º 31
0
        public static IEnumerable <ProductVM> GetMyProducts(int farmID)
        {
            FarmSaleDBEntities1     db       = new FarmSaleDBEntities1();
            IEnumerable <ProductVM> products =
                from f in db.Farms
                from fp in db.FarmProducts
                where farmID == fp.farmID && f.farmID == farmID
                from p in db.Products
                where p.productID == fp.productID
                select new ProductVM()
            {
                ProductName     = p.productName,
                Price           = (decimal)p.price,
                ProductCategory = p.productCategory,
                Description     = p.productDescription,
                Qty             = (int)p.qty,
                FarmName        = f.farmName
            };

            return(products);
        }