public CCategories AddCategory(string strCategory)
        {
            try
            {
                CDatabase   Database      = new CDatabase();
                CCategories Category      = new CCategories();
                int         intCategoryID = Database.InsertCategory(strCategory);

                if (intCategoryID > 0)
                {
                    Category.intCategoryID = intCategoryID;
                    Category.strCategory   = strCategory;
                    Category.ActionStatus  = CCategories.ActionStatusTypes.CategoryAdded;
                }
                else
                {
                    Category.ActionStatus = CCategories.ActionStatusTypes.CategoryAddFailed;
                }

                return(Category);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #2
0
        public CUser Login(string strUserName, string strPassword)
        {
            try
            {
                CDatabase Database = new CDatabase();
                CUser     User     = new CUser();

                int intUserID = Database.Login(strUserName, strPassword);

                if (intUserID > 0)
                {
                    // Login successful
                    User = GetUser(intUserID);
                    User.SetCurrentUser();
                    User.ActionStatus = ActionStatusTypes.UserLoggedIn;
                }
                else
                {
                    // Login failed
                    User.ActionStatus = ActionStatusTypes.FailedLogin;
                }

                return(User);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Example #3
0
        public int Save()
        {
            try
            {
                CDatabase Database = new CDatabase();
                if (this.ProductID != 0)
                {
                    Database.UpdateProduct(this);
                }
                else
                {
                    Database.InsertProduct(this);
                }

                if (this.PrimaryImage != null)
                {
                    this.UpdatePrimaryImage();
                }
                return(0); // Success
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #4
0
 public static List <CAddress> GetAddressList(int intUserId)
 {
     try
     {
         CDatabase       db        = new CDatabase();
         List <CAddress> Addresses = db.GetAddressList(intUserId);
         return(Addresses);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Example #5
0
 public static CAddress GetDefaultAddress(int intUserId)
 {
     try
     {
         CDatabase db      = new CDatabase();
         CAddress  Address = db.GetDefaultAddress(intUserId);
         return(Address);
     }
     catch (Exception)
     {
         return(null);
     }
 }
 public int DeleteCategory(int intCategoryID)
 {
     try
     {
         CDatabase db = new CDatabase();
         db.DeleteCategory(intCategoryID);
         return(3); // success
     }
     catch (Exception)
     {
         return(4); // Failure
     }
 }
 public static List <CCategories> GetCategories()
 {
     try
     {
         CDatabase          db         = new CDatabase();
         List <CCategories> Categories = db.GetCategories();
         return(Categories);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Example #8
0
 public static COrder GetOrder(int intOrderID, int intUserID, int blnCart)
 {
     try
     {
         CDatabase db    = new CDatabase();
         COrder    Order = db.GetOrder(intOrderID, intUserID, blnCart);
         return(Order);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Example #9
0
 public static CProduct GetProduct(int intProductID)
 {
     try
     {
         CDatabase       db       = new CDatabase();
         List <CProduct> Products = db.GetProducts(intProductID);
         return(Products[0]);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Example #10
0
 public int DeleteAddress(int intAddressID, int intUserID = 0)
 {
     try
     {
         CDatabase db = new CDatabase();
         db.DeleteAddress(intAddressID, intUserID);
         return(3); // success
     }
     catch (Exception)
     {
         return(4); // Failure
     }
 }
Example #11
0
 public static List <CProduct> GetProducts()
 {
     try
     {
         CDatabase       db       = new CDatabase();
         List <CProduct> Products = db.GetProducts();
         return(Products);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Example #12
0
 public int Delete()
 {
     try
     {
         CDatabase db = new CDatabase();
         db.DeleteProduct(this.ProductID);
         return(0);                // success
     }
     catch (Exception)
     {
         return(-1);
     }
 }
 public static CCategories GetCategory(int intCategoryID)
 {
     try
     {
         CDatabase          db         = new CDatabase();
         List <CCategories> Categories = db.GetCategories(intCategoryID);
         return(Categories[0]);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Example #14
0
 public static int UpdateOrder(COrder Order)
 {
     try
     {
         CDatabase db = new CDatabase();
         db.UpdateOrder(Order);
         return(0);
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Example #15
0
 public int AddPrimaryImage()
 {
     try
     {
         CDatabase Database = new CDatabase();
         CImage    NewImage = new CImage();
         Database.InsertProductImage(this.ProductID, this.PrimaryImage.FileName, this.PrimaryImage.FileExtension, this.PrimaryImage.FileSize, this.PrimaryImage.FileBytes);
         return(0);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Example #16
0
        public int AddAddress(CAddress Address)
        {
            try
            {
                CDatabase   Database     = new CDatabase();
                CCategories Category     = new CCategories();
                int         intAddressID = Database.InsertAddress(Address);

                return(intAddressID);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #17
0
        public static CUser GetUser(int intUserID)
        {
            try
            {
                CUser     User = new CUser();
                CDatabase db   = new CDatabase();

                User = db.GetUser(intUserID);

                return(User);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Example #18
0
        public int UpdatePrimaryImage()
        {
            try
            {
                CDatabase Database = new CDatabase();
                CImage    NewImage = new CImage();

                int intImageID;
                NewImage   = Database.GetPrimaryImage(this.ProductID);
                intImageID = NewImage.ImageID;

                Database.UpdateProductImage(intImageID, this.ProductID, this.PrimaryImage.FileName, this.PrimaryImage.FileExtension, this.PrimaryImage.FileSize, this.PrimaryImage.FileBytes);
                return(0);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #19
0
 public CUser.ActionStatusTypes Save()
 {
     try
     {
         CDatabase Database = new CDatabase();
         if (this.UserID == 0)
         {
             this.ActionStatus = Database.InsertUser(this);
         }
         else
         {
             this.ActionStatus = Database.UpdateUser(this);
         }
         return(ActionStatus);
     }
     catch (Exception)
     {
         return(ActionStatusTypes.Unknown);
     }
 }
Example #20
0
 public int ToggleCart(int intProductID, int intUserID)
 {
     try
     {
         CDatabase db = new CDatabase();
         if (db.ToggleCart(intUserID, intProductID) == 1)
         {
             return(1); // Toggled on
         }
         else if (db.ToggleCart(intUserID, intProductID) == -1)
         {
             return(-1); // Toggled off
         }
         else
         {
             return(0); // Failed
         }
     }
     catch (Exception)
     {
         return(0);
     }
 }
Example #21
0
        public int DoesAddressExist(CAddress NewAddress)
        {
            try
            {
                CDatabase       db          = new CDatabase();
                List <CAddress> AddressList = db.GetAddressList();

                foreach (CAddress Address in AddressList)
                {
                    if (NewAddress.intStateID == Address.intStateID &&
                        NewAddress.strAddress == Address.strAddress &&
                        NewAddress.strCity == Address.strCity &&
                        NewAddress.strZipCode == Address.strZipCode)
                    {
                        return(Address.intAddressID); // match found
                    }
                }
                return(0); // No match found
            }
            catch (Exception)
            {
                return(-1); // Failure
            }
        }