Exemple #1
0
        /// <summary>
        /// Purpose: Grabs category information based on ID
        /// Accepts: Int
        /// Returns: Hashtable
        /// </summary>
        public Hashtable GetCategoryByID(int id)
        {
            Category obj = new Category();
            QuickStart_DBEntities dbContext;
            Hashtable             hsh = new Hashtable();

            try
            {
                dbContext = new QuickStart_DBEntities();
                obj       = dbContext.Categories.FirstOrDefault(c => c.CategoryID == id);
                if (obj != null)
                {
                    hsh["categoryid"]       = obj.CategoryID;
                    hsh["name"]             = obj.Name;
                    hsh["description"]      = obj.Description;
                    hsh["parentcategoryid"] = obj.ParentCategoryID;
                    hsh["created"]          = obj.Created;
                    hsh["modified"]         = obj.Modified;
                    hsh["isactive"]         = obj.IsActive;
                }
            }
            catch (Exception ex)
            {
                ErrorLoggerData.ErrorRoutine(ex, "CategoryData", "GetCategoryByID");
            }

            return(hsh);
        }
Exemple #2
0
        /// <summary>
        /// Purpose: Grabs all categories
        /// Accepts: Boolean
        /// Returns: List<Category>
        /// </summary>
        public List <Category> GetAllCategories(bool onlyActive)
        {
            QuickStart_DBEntities dbContext;
            List <Category>       allCategories = null;

            try
            {
                dbContext = new QuickStart_DBEntities();

                if (onlyActive == true) //only the active categories are returned
                {
                    allCategories = dbContext.Categories.Where(c => c.IsActive == true).ToList();
                }
                else //all categories are returned
                {
                    allCategories = dbContext.Categories.ToList();
                }
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "CategoryData", "GetAllCategories");
            }

            return(allCategories);
        }
Exemple #3
0
        /// <summary>
        /// Purpose: Grabs audit information based on ID
        /// Accepts: Int
        /// Returns: Hashtable
        /// </summary>
        public Hashtable GetAuditByID(int id)
        {
            Audit obj = new Audit();
            QuickStart_DBEntities dbContext;
            Hashtable             hsh = new Hashtable();

            try
            {
                dbContext = new QuickStart_DBEntities();
                obj       = dbContext.Audits.FirstOrDefault(a => a.AuditID == id);
                if (obj != null)
                {
                    hsh["auditid"]     = obj.AuditID;
                    hsh["audittypeid"] = obj.AuditTypeID;
                    hsh["userid"]      = obj.UserID;
                    hsh["adminid"]     = obj.AdminID;
                    hsh["notes"]       = obj.Notes;
                    hsh["created"]     = obj.Created;
                }
            }
            catch (Exception ex)
            {
                ErrorLoggerData.ErrorRoutine(ex, "AuditData", "GetAuditByID");
            }

            return(hsh);
        }
Exemple #4
0
        /// <summary>
        /// Purpose: Grabs administrator ID based on administrator login information
        /// Accepts: Hashtable
        /// Returns: Int
        /// </summary>
        public int Login(Hashtable hsh)
        {
            QuickStart_DBEntities dbContext;
            int retAdminID = -1;

            try
            {
                String username = Convert.ToString(hsh["username"]);
                String password = Convert.ToString(hsh["password"]);

                dbContext = new QuickStart_DBEntities();

                //Use Linq to Entities syntax to retrieve desired Administrator
                Administrator admin = null;
                admin = dbContext.Administrators.FirstOrDefault(a => a.Username == username);

                if (admin != null)
                {
                    if (admin.Password == password)
                    {
                        retAdminID = admin.AdministratorID;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLoggerData.ErrorRoutine(ex, "AdministratorData", "Login");
                retAdminID = -1;
            }

            return(retAdminID);
        }
        /// <summary>
        /// Purpose: Grabs delivery type information based on ID
        /// Accepts: Int
        /// Returns: Hashtable
        /// </summary>
        public Hashtable GetDeliveryTypeByID(int id)
        {
            DeliveryType          obj = new DeliveryType();
            QuickStart_DBEntities dbContext;
            Hashtable             hsh = new Hashtable();

            try
            {
                dbContext = new QuickStart_DBEntities();
                obj       = dbContext.DeliveryTypes.FirstOrDefault(d => d.DeliveryTypeID == id);
                if (obj != null)
                {
                    hsh["deliverytypeid"] = obj.DeliveryTypeID;
                    hsh["name"]           = obj.Name;
                    hsh["description"]    = obj.Description;
                    hsh["cost"]           = obj.Cost;
                    hsh["created"]        = obj.Created;
                    hsh["modified"]       = obj.Modified;
                }
            }
            catch (Exception ex)
            {
                ErrorLoggerData.ErrorRoutine(ex, "DeliveryTypeData", "GetDeliveryTypeByID");
            }

            return(hsh);
        }
Exemple #6
0
        /// <summary>
        /// Purpose: Update an existing Order in the database
        /// Accepts: Hashtable
        /// Returns: Boolean
        /// </summary>
        public bool UpdateOrder(Hashtable hsh)
        {
            bool  isSuccess = false;
            Order order     = new Order();
            QuickStart_DBEntities dbContext;

            try
            {
                dbContext = new QuickStart_DBEntities();
                int orderid = Convert.ToInt32(hsh["orderid"]);
                order                = dbContext.Orders.FirstOrDefault(o => o.OrderID == orderid);
                order.UserID         = Convert.ToInt32(hsh["userid"]);
                order.Subtotal       = Convert.ToDouble(hsh["subtotal"]);
                order.Taxes          = Convert.ToDouble(hsh["taxes"]);
                order.DeliveryCost   = Convert.ToDouble(hsh["deliverycost"]);
                order.DeliveryTypeID = Convert.ToInt32(hsh["deliverytypeid"]);
                order.GrandTotal     = Convert.ToDouble(hsh["grandtotal"]);
                //need 'modified' but not 'created' during an update
                order.Modified = DateTime.Now;

                dbContext.SaveChanges();
                isSuccess = true;
            }
            catch (Exception e)
            {
                ErrorRoutine(e, "OrderData", "UpdateOrder");
            }

            return(isSuccess);
        }
        /// <summary>
        /// Purpose: Grabs configuration information based on configuration code
        /// Accepts: String
        /// Returns: Hashtable
        /// </summary>
        public Hashtable GetConfigurationByCode(string code)
        {
            Configuration         obj = new Configuration();
            QuickStart_DBEntities dbContext;
            Hashtable             hsh = new Hashtable();

            try
            {
                dbContext = new QuickStart_DBEntities();
                obj       = dbContext.Configurations.FirstOrDefault(c => c.ConfigurationCode == code);
                if (obj != null)
                {
                    hsh["configurationcode"] = obj.ConfigurationCode;
                    hsh["description"]       = obj.Description;
                    hsh["value"]             = obj.Value;
                    hsh["isyesnovalue"]      = obj.IsYesNoValue;
                    hsh["yesnovalue"]        = obj.YesNoValue;
                    hsh["modified"]          = obj.Modified;
                }
            }
            catch (Exception ex)
            {
                ErrorLoggerData.ErrorRoutine(ex, "ConfigurationData", "GetConfigurationByCode");
            }

            return(hsh);
        }
        /// <summary>
        /// Purpose: Grabs state/province information based on ID
        /// Accepts: Int
        /// Returns: Hashtable
        /// </summary>
        public Hashtable GetStateProvinceByID(int id)
        {
            StatesProvince        obj = new StatesProvince();
            QuickStart_DBEntities dbContext;
            Hashtable             hsh = new Hashtable();

            try
            {
                dbContext = new QuickStart_DBEntities();
                obj       = dbContext.StatesProvinces.FirstOrDefault(s => s.StateProvinceID == id);
                if (obj != null)
                {
                    hsh["stateprovinceid"]   = obj.StateProvinceID;
                    hsh["name"]              = obj.Name;
                    hsh["country"]           = obj.Country;
                    hsh["currencycode"]      = obj.CurrencyCode;
                    hsh["taxratepercentage"] = obj.TaxRatePercentage;
                    hsh["modified"]          = obj.Modified;
                }
            }
            catch (Exception ex)
            {
                ErrorLoggerData.ErrorRoutine(ex, "StateProvinceData", "GetStateProvinceByID");
            }

            return(hsh);
        }
Exemple #9
0
        /// <summary>
        /// Purpose: Grabs user ID based on user login information
        /// Accepts: Hashtable
        /// Returns: Int
        /// </summary>
        public int Login(Hashtable hsh)
        {
            QuickStart_DBEntities dbContext;
            int retUserID = -1;

            try
            {
                String username = Convert.ToString(hsh["username"]);
                String password = Convert.ToString(hsh["password"]);

                dbContext = new QuickStart_DBEntities();

                //Use Linq to Entities syntax to retrieve desired User
                User user = null;
                user = dbContext.Users.FirstOrDefault(u => u.Username == username);

                if (user != null)
                {
                    if (user.Password == password)
                    {
                        retUserID = user.UserID;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLoggerData.ErrorRoutine(ex, "UserData", "Login");
                retUserID = -1;
            }

            return(retUserID);
        }
Exemple #10
0
        /// <summary>
        /// Purpose: Add new user's information to the DB
        /// Accepts: Hashtable
        /// Returns: int
        /// </summary>
        public int AddUser(Hashtable hsh)
        {
            int  newId = -1;
            User usr   = new User();
            QuickStart_DBEntities dbContext;

            try
            {
                dbContext                = new QuickStart_DBEntities();
                usr.Username             = Convert.ToString(hsh["username"]);
                usr.Password             = Convert.ToString(hsh["password"]);
                usr.Salutation           = Convert.ToString(hsh["salutation"]);
                usr.FirstName            = Convert.ToString(hsh["firstName"]);
                usr.LastName             = Convert.ToString(hsh["lastName"]);
                usr.Address1             = Convert.ToString(hsh["address1"]);
                usr.Address2             = Convert.ToString(hsh["address2"]);
                usr.City                 = Convert.ToString(hsh["city"]);
                usr.StateProvinceID      = Convert.ToInt32(hsh["stateProv"]);
                usr.ZipPostalCode        = Convert.ToString(hsh["zipPC"]);
                usr.Email                = Convert.ToString(hsh["email"]);
                usr.IsReceiveNewsletters = Convert.ToBoolean(hsh["newsletters"]);
                usr.Created              = DateTime.Now;

                dbContext.AddToUsers(usr);
                dbContext.SaveChanges();
                newId = usr.UserID;
                dbContext.Detach(usr);
            }
            catch (Exception e)
            {
                ErrorLoggerData.ErrorRoutine(e, "UserData", "AddUser");
            }

            return(newId);
        }
Exemple #11
0
        /// <summary>
        /// Purpose: Grabs all administrators
        /// Accepts: Boolean
        /// Returns: List<Administrator>
        /// </summary>
        public List <Administrator> GetAllAdministrators(bool onlyActive)
        {
            QuickStart_DBEntities dbContext;
            List <Administrator>  alladministrators = null;

            try
            {
                dbContext = new QuickStart_DBEntities();

                if (onlyActive == true) //only the active administrators are returned
                {
                    alladministrators = dbContext.Administrators.Where(a => a.IsActive == true).ToList();
                }
                else //all administrators are returned
                {
                    alladministrators = dbContext.Administrators.ToList();
                }
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "AdministratorData", "GetAllAdministrators");
            }

            return(alladministrators);
        }
Exemple #12
0
        /// <summary>
        /// Purpose: Grabs all products for a given category id
        /// Accepts: Integer, Boolean
        /// Returns: List<Product>
        /// </summary>
        public List <Product> GetAllProductsByCategoryID(int catid, bool onlyActive)
        {
            QuickStart_DBEntities dbContext;
            List <Product>        allproducts = null;

            try
            {
                dbContext = new QuickStart_DBEntities();

                if (onlyActive == true) //only the active categories are returned
                {
                    allproducts = dbContext.Products.Where(p => p.isActive == true && p.CategoryID == catid).ToList();
                }
                else //all categories are returned
                {
                    allproducts = dbContext.Products.Where(p => p.CategoryID == catid).ToList();
                }
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "ProductData", "GetAllProductsByCategoryID");
            }

            return(allproducts);
        }
Exemple #13
0
        /// <summary>
        /// Purpose: Update an existing Product in the database
        /// Accepts: Hashtable
        /// Returns: Boolean
        /// </summary>
        public bool UpdateProduct(Hashtable hsh)
        {
            bool    isSuccess = false;
            Product prod      = new Product();
            QuickStart_DBEntities dbContext;

            try
            {
                dbContext = new QuickStart_DBEntities();
                string prodcd = hsh["productcode"].ToString();
                prod                     = dbContext.Products.FirstOrDefault(p => p.ProductCode == prodcd);
                prod.Name                = Convert.ToString(hsh["name"]);
                prod.Brand               = Convert.ToString(hsh["brand"]);
                prod.Description         = Convert.ToString(hsh["description"]);
                prod.CategoryID          = Convert.ToInt32(hsh["categoryid"]);
                prod.MSRP                = Convert.ToDouble(hsh["msrp"]);
                prod.isFreeShipping      = Convert.ToBoolean(hsh["isfreeshipping"]);
                prod.isTaxFree           = Convert.ToBoolean(hsh["istaxfree"]);
                prod.QuantityInStock     = Convert.ToInt32(hsh["quantityinstock"]);
                prod.IsQuantityUnlimited = Convert.ToBoolean(hsh["isquantityunlimited"]);
                //need 'modified' but not 'created' during an update
                prod.Modified = DateTime.Now;
                prod.isActive = Convert.ToBoolean(hsh["isactive"]);

                dbContext.SaveChanges();
                isSuccess = true;
            }
            catch (Exception e)
            {
                ErrorRoutine(e, "ProductData", "UpdateProduct");
            }

            return(isSuccess);
        }
Exemple #14
0
        /// <summary>
        /// Purpose: Grabs product information based on product code
        /// Accepts: String
        /// Returns: Hashtable
        /// </summary>
        public Hashtable GetProductByCode(string code)
        {
            Product obj = new Product();
            QuickStart_DBEntities dbContext;
            Hashtable             hsh = new Hashtable();

            try
            {
                dbContext = new QuickStart_DBEntities();
                obj       = dbContext.Products.FirstOrDefault(p => p.ProductCode == code);
                if (obj != null)
                {
                    hsh["productcode"]         = obj.ProductCode;
                    hsh["name"]                = obj.Name;
                    hsh["brand"]               = obj.Brand;
                    hsh["description"]         = obj.Description;
                    hsh["categoryid"]          = obj.CategoryID;
                    hsh["msrp"]                = obj.MSRP;
                    hsh["isfreeshipping"]      = obj.isFreeShipping;
                    hsh["istaxfree"]           = obj.isTaxFree;
                    hsh["quantityinstock"]     = obj.QuantityInStock;
                    hsh["isquantityunlimited"] = obj.IsQuantityUnlimited;
                    hsh["created"]             = obj.Created;
                    hsh["modified"]            = obj.Modified;
                    hsh["isactive"]            = obj.isActive;
                }
            }
            catch (Exception ex)
            {
                ErrorLoggerData.ErrorRoutine(ex, "ProductData", "GetProductByCode");
            }

            return(hsh);
        }
        /// <summary>
        /// Purpose: Grabs product delivery type information based on ID
        /// Accepts: Int
        /// Returns: Hashtable
        /// </summary>
        public Hashtable GetProductDeliveryTypeByID(int id)
        {
            ProductDeliveryType   obj = new ProductDeliveryType();
            QuickStart_DBEntities dbContext;
            Hashtable             hsh = new Hashtable();

            try
            {
                dbContext = new QuickStart_DBEntities();
                obj       = dbContext.ProductDeliveryTypes.FirstOrDefault(d => d.ProductDeliveryTypeID == id);
                if (obj != null)
                {
                    hsh["productdeliverytypeid"] = obj.ProductDeliveryTypeID;
                    hsh["deliverytypeid"]        = obj.DeliveryTypeID;
                    hsh["productcode"]           = obj.ProductCode;
                    hsh["created"]  = obj.Created;
                    hsh["modified"] = obj.Modified;
                }
            }
            catch (Exception ex)
            {
                ErrorLoggerData.ErrorRoutine(ex, "ProductDeliveryTypeData", "GetProductDeliveryTypeByID");
            }

            return(hsh);
        }
Exemple #16
0
        /// <summary>
        /// Purpose: Grabs order information based on ID
        /// Accepts: Int
        /// Returns: Hashtable
        /// </summary>
        public Hashtable GetOrderByID(int id)
        {
            Order obj = new Order();
            QuickStart_DBEntities dbContext;
            Hashtable             hsh = new Hashtable();

            try
            {
                dbContext = new QuickStart_DBEntities();
                obj       = dbContext.Orders.FirstOrDefault(o => o.OrderID == id);
                if (obj != null)
                {
                    hsh["orderid"]        = obj.OrderID;
                    hsh["userid"]         = obj.UserID;
                    hsh["subtotal"]       = obj.Subtotal;
                    hsh["taxes"]          = obj.Taxes;
                    hsh["deliverytypeid"] = obj.DeliveryTypeID;
                    hsh["deliverycost"]   = obj.DeliveryCost;
                    hsh["grandtotal"]     = obj.GrandTotal;
                    hsh["created"]        = obj.Created;
                    hsh["modified"]       = obj.Modified;
                }
            }
            catch (Exception ex)
            {
                ErrorLoggerData.ErrorRoutine(ex, "OrderData", "GetOrderByID");
            }

            return(hsh);
        }
Exemple #17
0
        /// <summary>
        /// Purpose: Grabs administrator information based on ID
        /// Accepts: Int
        /// Returns: Hashtable
        /// </summary>
        public Hashtable GetAdministratorByID(int id)
        {
            Administrator         obj = new Administrator();
            QuickStart_DBEntities dbContext;
            Hashtable             hsh = new Hashtable();

            try
            {
                dbContext = new QuickStart_DBEntities();
                obj       = dbContext.Administrators.FirstOrDefault(a => a.AdministratorID == id);
                if (obj != null)
                {
                    hsh["adminid"]   = obj.AdministratorID;
                    hsh["username"]  = obj.Username;
                    hsh["password"]  = obj.Password;
                    hsh["firstname"] = obj.FirstName;
                    hsh["lastname"]  = obj.LastName;
                    hsh["isactive"]  = obj.IsActive;
                }
            }
            catch (Exception ex)
            {
                ErrorLoggerData.ErrorRoutine(ex, "AdministratorData", "GetAdministratorByID");
            }

            return(hsh);
        }
Exemple #18
0
        /// <summary>
        /// Purpose: Grabs orderitem information based on ID
        /// Accepts: Int
        /// Returns: Hashtable
        /// </summary>
        public Hashtable GetOrderItemByID(int id)
        {
            OrderItem             obj = new OrderItem();
            QuickStart_DBEntities dbContext;
            Hashtable             hsh = new Hashtable();

            try
            {
                dbContext = new QuickStart_DBEntities();
                obj       = dbContext.OrderItems.FirstOrDefault(o => o.OrderItemID == id);
                if (obj != null)
                {
                    hsh["orderitemid"] = obj.OrderItemID;
                    hsh["orderid"]     = obj.OrderID;
                    hsh["productcode"] = obj.ProductCode;
                    hsh["quantity"]    = obj.Quantity;
                    hsh["created"]     = obj.Created;
                    hsh["modified"]    = obj.Modified;
                }
            }
            catch (Exception ex)
            {
                ErrorLoggerData.ErrorRoutine(ex, "OrderItemData", "GetOrderItemByID");
            }

            return(hsh);
        }
Exemple #19
0
        /// <summary>
        /// Purpose: Grabs all users
        /// Accepts: Nothing
        /// Returns: List<User>
        /// </summary>
        public List <User> GetAllUsers()
        {
            QuickStart_DBEntities dbContext;
            List <User>           allusers = null;

            try
            {
                dbContext = new QuickStart_DBEntities();

                //all users are returned
                allusers = dbContext.Users.ToList();
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "UserData", "GetAllUsers");
            }

            return(allusers);
        }
        /// <summary>
        /// Purpose: Grabs all configuration settings
        /// Accepts: Nothing
        /// Returns: List<Configuration>
        /// </summary>
        public List <Configuration> GetAllConfigurations()
        {
            QuickStart_DBEntities dbContext;
            List <Configuration>  allconfigs = null;

            try
            {
                dbContext = new QuickStart_DBEntities();

                //all configurations are returned
                allconfigs = dbContext.Configurations.ToList();
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "ConfigurationData", "GetAllConfigurations");
            }

            return(allconfigs);
        }
        /// <summary>
        /// Purpose: Grabs all product delivery types by product code
        /// Accepts: String (Product Code)
        /// Returns: List<ProductDeliveryType>
        /// </summary>
        public List <ProductDeliveryType> GetAllProductDeliveryTypesByProdCode(string prodcd)
        {
            QuickStart_DBEntities      dbContext;
            List <ProductDeliveryType> proddeliverytypes = null;

            try
            {
                dbContext = new QuickStart_DBEntities();

                //all product delivery types for this product are returned
                proddeliverytypes = dbContext.ProductDeliveryTypes.Where(pdt => pdt.ProductCode == prodcd).ToList();
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "ProductDeliveryTypeData", "GetAllDeliveryTypesByProdCode");
            }

            return(proddeliverytypes);
        }
Exemple #22
0
        /// <summary>
        /// Purpose: Grabs all InvoiceItems via stored procedure
        /// Accepts: Nothing
        /// Returns: List<InvoiceItem>
        /// </summary>
        public List <InvoiceItem> GetAllInvoiceItemsByOrderID(int orderid)
        {
            QuickStart_DBEntities dbContext;
            List <InvoiceItem>    retList = null;

            try
            {
                dbContext = new QuickStart_DBEntities();

                //all Invoice Items are returned for this order id
                retList = dbContext.GetInvoiceItemsByOrderID(orderid).ToList();
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "InvoiceItemData", "GetAllInvoiceItemsByOrderID");
            }

            return(retList);
        }
Exemple #23
0
        /// <summary>
        /// Purpose: Grabs all order items
        /// Accepts: Nothing
        /// Returns: List<OrderItem>
        /// </summary>
        public List <OrderItem> GetAllOrderItems()
        {
            QuickStart_DBEntities dbContext;
            List <OrderItem>      allorderitems = null;

            try
            {
                dbContext = new QuickStart_DBEntities();

                //all order items are returned
                allorderitems = dbContext.OrderItems.ToList();
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "OrderItemData", "GetAllOrderItems");
            }

            return(allorderitems);
        }
        /// <summary>
        /// Purpose: Grabs all StatesProvinces
        /// Accepts: Nothing
        /// Returns: List<StatesProvince>
        /// </summary>
        public List <StatesProvince> GetAllStatesProvinces()
        {
            QuickStart_DBEntities dbContext;
            List <StatesProvince> allstatesprovinces = null;

            try
            {
                dbContext = new QuickStart_DBEntities();

                //all states/provinces are returned
                allstatesprovinces = dbContext.StatesProvinces.ToList();
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "StatesProvinceData", "GetAllStatesProvinces");
            }

            return(allstatesprovinces);
        }
Exemple #25
0
        /// <summary>
        /// Purpose: Grabs all language labels
        /// Accepts: Nothing
        /// Returns: List<LanguageLabel>
        /// </summary>
        public List <LangLabel> GetAllLangLabels()
        {
            QuickStart_DBEntities dbContext;
            List <LangLabel>      alllanglabels = null;

            try
            {
                dbContext = new QuickStart_DBEntities();

                //all language labels are returned
                alllanglabels = dbContext.LangLabels.ToList();
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "LangLabelData", "GetAllLangLabels");
            }

            return(alllanglabels);
        }
        /// <summary>
        /// Purpose: Grabs all product delivery types
        /// Accepts: Nothing
        /// Returns: List<ProductDeliveryType>
        /// </summary>
        public List <ProductDeliveryType> GetAllProductDeliveryTypes()
        {
            QuickStart_DBEntities      dbContext;
            List <ProductDeliveryType> allproddeliverytypes = null;

            try
            {
                dbContext = new QuickStart_DBEntities();

                //all product delivery types are returned
                allproddeliverytypes = dbContext.ProductDeliveryTypes.ToList();
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "ProductDeliveryTypeData", "GetAllProductDeliveryTypes");
            }

            return(allproddeliverytypes);
        }
Exemple #27
0
        /// <summary>
        /// Purpose: Grabs all orders
        /// Accepts: Int representing the userID
        /// Returns: List<Order>
        /// </summary>
        public List <Order> GetAllOrdersByUserID(int uId)
        {
            QuickStart_DBEntities dbContext;
            List <Order>          allorders = null;

            try
            {
                dbContext = new QuickStart_DBEntities();

                //all orders are returned
                allorders = dbContext.Orders.Where(o => o.UserID == uId).ToList();
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "OrderData", "GetAllOrders");
            }

            return(allorders);
        }
Exemple #28
0
        /// <summary>
        /// Purpose: Grabs all audit types
        /// Accepts: Nothing
        /// Returns: List<AuditType>
        /// </summary>
        public List <AuditType> GetAllAuditTypes()
        {
            QuickStart_DBEntities dbContext;
            List <AuditType>      allaudittypes = null;

            try
            {
                dbContext = new QuickStart_DBEntities();

                //all audit types are returned
                allaudittypes = dbContext.AuditTypes.ToList();
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "AuditTypeData", "GetAllAuditTypes");
            }

            return(allaudittypes);
        }
Exemple #29
0
        /// <summary>
        /// Purpose: Update an existing User in the database
        /// Accepts: Hashtable
        /// Returns: Boolean
        /// </summary>
        public bool UpdateUser(Hashtable hsh)
        {
            bool isSuccess = false;
            User usr       = new User();
            QuickStart_DBEntities dbContext;

            try
            {
                dbContext = new QuickStart_DBEntities();

                //Get the user to update based on its id
                int userid = Convert.ToInt32(hsh["userid"]);
                usr = dbContext.Users.FirstOrDefault(u => u.UserID == userid);

                usr.Username             = Convert.ToString(hsh["username"]);
                usr.Password             = Convert.ToString(hsh["password"]);
                usr.Salutation           = Convert.ToString(hsh["salutation"]);
                usr.FirstName            = Convert.ToString(hsh["firstName"]);
                usr.LastName             = Convert.ToString(hsh["lastName"]);
                usr.Address1             = Convert.ToString(hsh["address1"]);
                usr.Address2             = Convert.ToString(hsh["address2"]);
                usr.City                 = Convert.ToString(hsh["city"]);
                usr.StateProvinceID      = Convert.ToInt32(hsh["stateProv"]);
                usr.ZipPostalCode        = Convert.ToString(hsh["zipPC"]);
                usr.Email                = Convert.ToString(hsh["email"]);
                usr.IsReceiveNewsletters = Convert.ToBoolean(hsh["newsletters"]);
                //need 'modified' but not 'created' during an update
                usr.Modified = DateTime.Now;

                dbContext.SaveChanges();
                isSuccess = true;
            }
            catch (Exception e)
            {
                ErrorRoutine(e, "UserData", "UpdateUser");
            }

            return(isSuccess);
        }
Exemple #30
0
        /// <summary>
        /// Purpose: Grabs user information based on ID
        /// Accepts: Int
        /// Returns: Hashtable
        /// </summary>
        public Hashtable GetUserByID(int id)
        {
            User obj = new User();
            QuickStart_DBEntities dbContext;
            Hashtable             hsh = new Hashtable();

            try
            {
                dbContext = new QuickStart_DBEntities();
                obj       = dbContext.Users.FirstOrDefault(u => u.UserID == id);
                if (obj != null)
                {
                    hsh["userid"]               = obj.UserID;
                    hsh["username"]             = obj.Username;
                    hsh["password"]             = obj.Password;
                    hsh["salutation"]           = obj.Salutation;
                    hsh["firstname"]            = obj.FirstName;
                    hsh["lastname"]             = obj.LastName;
                    hsh["address1"]             = obj.Address1;
                    hsh["address2"]             = obj.Address2;
                    hsh["city"]                 = obj.City;
                    hsh["stateprovinceid"]      = obj.StateProvinceID;
                    hsh["zippostalcode"]        = obj.ZipPostalCode;
                    hsh["email"]                = obj.Email;
                    hsh["isreceivenewsletters"] = obj.IsReceiveNewsletters;
                    hsh["created"]              = obj.Created;
                    hsh["modified"]             = obj.Modified;
                }
            }
            catch (Exception ex)
            {
                ErrorLoggerData.ErrorRoutine(ex, "UserData", "GetUserByID");
            }

            return(hsh);
        }