/// <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); }
/// <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 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); }
/// <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); }
/// <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 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 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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <summary> /// Purpose: Grabs audit type information based on ID /// Accepts: Int /// Returns: Hashtable /// </summary> public Hashtable GetAuditTypeByID(int id) { AuditType obj = new AuditType(); QuickStart_DBEntities dbContext; Hashtable hsh = new Hashtable(); try { dbContext = new QuickStart_DBEntities(); obj = dbContext.AuditTypes.FirstOrDefault(a => a.AuditTypeID == id); if (obj != null) { hsh["audittypeid"] = obj.AuditTypeID; hsh["description"] = obj.Description; hsh["isadmin"] = obj.IsAdmin; } } catch (Exception ex) { ErrorLoggerData.ErrorRoutine(ex, "AuditTypeData", "GetAuditTypeByID"); } return(hsh); }
/// <summary> /// Purpose: Grabs language label information based on language label code /// Accepts: String /// Returns: Hashtable /// </summary> public Hashtable GetLangLabelByCode(string code) { LangLabel obj = new LangLabel(); QuickStart_DBEntities dbContext; Hashtable hsh = new Hashtable(); try { dbContext = new QuickStart_DBEntities(); obj = dbContext.LangLabels.FirstOrDefault(l => l.LangLabelCode == code); if (obj != null) { hsh["langlabelcode"] = obj.LangLabelCode; hsh["value"] = obj.Value; hsh["modified"] = obj.Modified; } } catch (Exception ex) { ErrorLoggerData.ErrorRoutine(ex, "LangLabelData", "GetLangLabelByCode"); } return(hsh); }