Beispiel #1
0
        ///////
        /// <summary>
        /// Add Product
        /// </summary>
        /// <param name="product">AddProduct</param>
        public void AddProduct(Product product)
        {
            var db = new LLDbContext();

            db.Products.Add(product);
            db.SaveChanges();
        }
        //Method to add content to the database.
        public void AddContent(Content contentToBeAdded)
        {
            LLDbContext contentDB = new LLDbContext();

            contentDB.Content.Add(contentToBeAdded);
            contentDB.SaveChanges();
        }
Beispiel #3
0
        // Add new Member to database
        public void AddMember(Member member)
        {
            var db = new LLDbContext();

            db.Members.Add(member);
            db.SaveChanges();
        }
        //Method to retrieve a specific section of content via its ContentID.  ContentID may be switched from string to integer later.
        public Content GetContent(string contentID)
        {
            LLDbContext contentDB = new LLDbContext();

            Content selectedContent = (from content in contentDB.Content
                                       where contentID == content.ContentID
                                       select content).FirstOrDefault <Content>();

            return(selectedContent);
        }
 /// <summary>
 /// Delete Product
 /// </summary>
 /// <param name="productID">DeleteProduct</param>
 /// <returns></returns>
 public Product DeleteProduct(int productID)
 {
     var db = new LLDbContext();
     Product dbEntry = db.Products.Find(productID);
     if (dbEntry != null)
     {
         db.Products.Remove(dbEntry);
         db.SaveChanges();
     }
     return dbEntry;
 }
Beispiel #6
0
        // Deletes member from database
        public Member DeleteMember(int memberId)
        {
            var    db      = new LLDbContext();
            Member dbEntry = db.Members.Find(memberId);

            if (dbEntry != null)
            {
                db.Members.Remove(dbEntry);
                db.SaveChanges();
            }
            return(dbEntry);
        }
Beispiel #7
0
        /// <summary>
        /// Delete Product
        /// </summary>
        /// <param name="productID">DeleteProduct</param>
        /// <returns></returns>
        public Product DeleteProduct(int productID)
        {
            var     db      = new LLDbContext();
            Product dbEntry = db.Products.Find(productID);

            if (dbEntry != null)
            {
                db.Products.Remove(dbEntry);
                db.SaveChanges();
            }
            return(dbEntry);
        }
        //To be used in conjunction with the UpdateSection method of the Content class.
        //This will take the content object passed in, attempt to find it in the database, and then update the information in the database.
        public void SaveContent(Content content)
        {
            LLDbContext contentDB = new LLDbContext();

            //Find the content in the DB:
            Content contentToUpdate = contentDB.Content.Find(content.ContentID);

            if (contentToUpdate != null)
            {
                //Edit its existing content to reflect the changes.
                //Take the entry in the database and make it have the new (updated) text from the object passed in as a parameter.
                contentToUpdate.CurrentText = content.NewText;
            }

            contentDB.SaveChanges();
        }
Beispiel #9
0
        // Saves member information to database
        public void SaveMember(Member member)
        {
            var db = new LLDbContext();

            if (member.MemberId == 0)
            {
                db.Members.Add(member);
            }
            else
            {
                // If member exists, it updates information
                Member dbEntry = db.Members.Find(member.MemberId);
                if (dbEntry != null)
                {
                    dbEntry.LoginName = member.LoginName;
                    dbEntry.Password  = member.Password;
                    dbEntry.FirstName = member.FirstName;
                    dbEntry.LastName  = member.LastName;
                    dbEntry.Email     = member.Email;
                }
            }
            db.SaveChanges();
        }
Beispiel #10
0
        /// <summary>
        /// Save Product
        /// </summary>
        /// <param name="product">Save Product</param>
        public void SaveProduct(Product product)
        {
            var db = new LLDbContext();

            if (product.ProductID == 0)
            {
                db.Products.Add(product);
            }
            else
            {
                Product dbEntry = db.Products.Find(product.ProductID);
                if (dbEntry != null)
                {
                    dbEntry.ProductName = product.ProductName;
                    dbEntry.Price       = product.Price;
                    dbEntry.Shipping    = product.Shipping;
                    dbEntry.Category    = product.Category;
                    dbEntry.Description = product.Description;
                    dbEntry.InStock     = product.InStock;//May be disabled if not used?! but must be done in all refd
                }
            }
            db.SaveChanges();
        }
Beispiel #11
0
        // Returns a singe member by Login name
        public Member GetMemberbyLoginName(string loginName)
        {
            var db = new LLDbContext();

            return(db.Members.First(m => m.LoginName == loginName));
        }
Beispiel #12
0
        public Product GetProductByProductName(string productName)
        {
            var db = new LLDbContext();

            return(db.Products.First(p => p.ProductName == productName));
        }
Beispiel #13
0
        /// <summary>
        /// Get Product By ID
        /// </summary>
        /// <param name="productID">GetProductByID</param>
        /// <returns>ProductByID</returns>
        public Product GetProductByProductID(int productID)
        {
            var db = new LLDbContext();

            return(db.Products.First(p => p.ProductID == productID));
        }
 /// <summary>
 /// Save Product
 /// </summary>
 /// <param name="product">Save Product</param>
 public void SaveProduct(Product product)
 {
     var db = new LLDbContext();
     if (product.ProductID == 0)
     {
         db.Products.Add(product);
     }
     else
     {
         Product dbEntry = db.Products.Find(product.ProductID);
         if (dbEntry != null)
         {
             dbEntry.ProductName = product.ProductName;
             dbEntry.Price = product.Price;
             //dbEntry.Shipping = product.Shipping;
             dbEntry.Category = product.Category;
             dbEntry.Description = product.Description;
             dbEntry.InStock = product.InStock;//May be disabled if not used?! but must be done in all refd
         }
     }
     db.SaveChanges();
 }
 public Product GetProductByProductName(string productName)
 {
     var db = new LLDbContext();
     return (db.Products.First(p => p.ProductName == productName));
 }
 /// <summary>
 /// Get Product By ID
 /// </summary>
 /// <param name="productID">GetProductByID</param>
 /// <returns>ProductByID</returns>
 public Product GetProductByProductID(int productID)
 {
     var db = new LLDbContext();
     return (db.Products.First(p => p.ProductID == productID));
 }
 ///////
 /// <summary>
 /// Add Product
 /// </summary>
 /// <param name="product">AddProduct</param>
 public void AddProduct(Product product)
 {
     var db = new LLDbContext();
     db.Products.Add(product);
     db.SaveChanges();
 }