Пример #1
0
        public ActionResult MyProfile(FormCollection Collection)
        {
            try
            {
                Models.CUser User        = new Models.CUser();
                Models.CUser CurrentUser = User.GetCurrentUser();

                User.UserID       = CurrentUser.UserID;
                User.EmailAddress = Collection["EmailAddress"];
                User.FirstName    = Collection["FirstName"];
                User.LastName     = Collection["LastName"];
                User.Password     = Collection["Password"];

                Models.CUser.ActionStatusTypes Status = User.Save();
                switch (Status)
                {
                case Models.CUser.ActionStatusTypes.UserAlreadyExists:
                    break;

                case Models.CUser.ActionStatusTypes.UserUpdated:
                    CurrentUser = null;
                    User.SetCurrentUser();
                    return(RedirectToAction("Home", "Home"));

                default:
                    break;
                }
                return(View(User));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #2
0
        public ActionResult Addresses()
        {
            try
            {
                Models.CUser           User           = new Models.CUser();
                Models.CAddress        DefaultAddress = new Models.CAddress();
                List <Models.CAddress> AddressList    = new List <Models.CAddress>();
                User = User.GetCurrentUser();

                DefaultAddress  = Models.CAddress.GetDefaultAddress(User.UserID);
                User.intStateID = DefaultAddress.intStateID;
                User.strCity    = DefaultAddress.strCity;
                User.strAddress = DefaultAddress.strAddress;
                User.strZipCode = DefaultAddress.strZipCode;

                AddressList = Models.CAddress.GetAddressList(User.UserID);

                if (AddressList.Count > 1)
                {
                    User.AddressList = AddressList;
                }

                return(View(User));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #3
0
 public ActionResult MyProducts()
 {
     Models.CUser User = new Models.CUser();
     User             = User.GetCurrentUser();
     User.ProductList = Models.CProduct.GetProducts();
     return(View(User));
 }
Пример #4
0
        public ActionResult Confirmation()
        {
            int ID = Convert.ToInt32(RouteData.Values["ID"]);

            Models.CUser           User        = new Models.CUser();
            Models.COrder          order       = new Models.COrder();
            Models.CDatabase       db          = new Models.CDatabase();
            List <Models.CProduct> productList = new List <Models.CProduct>();

            User        = User.GetCurrentUser();
            order       = Models.COrder.GetOrder(0, User.UserID, 1);
            productList = db.GetCart(User.UserID);

            // Update Order Information
            order.intStatusID = 2;
            db.UpdateOrder(order);

            // Update Product Stock amount
            foreach (Models.CProduct product in productList)
            {
                product.intStockAmount = product.intStockAmount - 1;
                db.UpdateProduct(product);
            }
            return(View(User));
        }
Пример #5
0
 public ActionResult Cart()
 {
     Models.CUser     User = new Models.CUser();
     Models.CDatabase db   = new Models.CDatabase();
     User = User.GetCurrentUser();
     if (User != null && User.UserID > 0)
     {
         User.Cart = db.GetCart(User.UserID);
     }
     return(View(User));
 }
Пример #6
0
        public ActionResult Categories()
        {
            Models.CUser User = new Models.CUser();
            User = User.GetCurrentUser();

            Models.CCategories categories = new Models.CCategories();
            categories.CategoryList = Models.CCategories.GetCategories();
            categories.UserID       = User.UserID;

            return(View(categories));
        }
Пример #7
0
        public ActionResult Payment(FormCollection Collection)
        {
            //if returnvalue == 'Approved'
            //  SuccessPage

            //'Failed'

            //
            Models.CUser User = new Models.CUser();
            User = User.GetCurrentUser();
            return(View(User));
        }
Пример #8
0
        public ActionResult Cart()
        {
            Models.CUser     User    = new Models.CUser();
            Models.CProduct  product = new Models.CProduct();
            Models.CDatabase db      = new Models.CDatabase();
            User = User.GetCurrentUser();
            double dblSubTotal = 0;

            if (User != null && User.UserID > 0)
            {
                User.Cart = db.GetCart(User.UserID);

                for (int i = 0; i < User.Cart.Count(); i++)
                {
                    dblSubTotal += User.Cart[i].Price;
                }

                User.CartSubTotal = dblSubTotal;
            }
            return(View(User));
        }
Пример #9
0
        public ActionResult Addresses(FormCollection Collection)
        {
            try
            {
                Models.CUser     User           = new Models.CUser();
                Models.CDatabase db             = new Models.CDatabase();
                Models.CAddress  EnteredAddress = new Models.CAddress();
                Models.COrder    order          = new Models.COrder();
                Models.CUser     user           = new Models.CUser();
                int intAddressID;

                EnteredAddress.strAddress = Collection["strAddress"];
                EnteredAddress.strCity    = Collection["strCity"];
                EnteredAddress.intStateID = Convert.ToInt32(Collection["intStateID"]);
                EnteredAddress.strZipCode = Collection["strZipCode"];

                intAddressID = EnteredAddress.DoesAddressExist(EnteredAddress);

                user  = user.GetCurrentUser();
                order = Models.COrder.GetOrder(0, user.UserID, 1);

                if (intAddressID > 0)
                {
                    order.intShippingAddressID = intAddressID;
                    db.UpdateOrder(order);
                }
                else
                {
                    intAddressID = db.InsertAddress(EnteredAddress);
                    order.intShippingAddressID = intAddressID;
                    db.UpdateOrder(order);
                }

                return(RedirectToAction("Payment"));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #10
0
 public ActionResult MyProduct()
 {
     Models.CUser User = new Models.CUser();
     User = User.GetCurrentUser();
     if (User.ProductList != null)
     {
         User.ProductList.Clear();
     }
     else
     {
         User.ProductList = new List <Models.CProduct>();
     }
     Models.CProduct Product = new Models.CProduct();
     if (RouteData.Values["id"] != null)
     {
         Product = Models.CProduct.GetProduct(Convert.ToInt32(RouteData.Values["id"]));
         User.ProductList.Add(Product);
     }
     else
     {
         User.ProductList.Add(Product);
     }
     return(View(User));
 }
Пример #11
0
        public ActionResult MyProduct(HttpPostedFileBase PrimaryImage, FormCollection Collection)
        {
            try
            {
                // Cancel
                if (Collection["btnSubmit"] == "cancel")
                {
                    return(RedirectToAction("MyProducts"));
                }

                Models.CDatabase db      = new Models.CDatabase();
                Models.CProduct  Product = new Models.CProduct();
                Models.CUser     User    = new Models.CUser();
                User = User.GetCurrentUser();
                Product.ProductID = (Convert.ToInt32(RouteData.Values["id"]));

                // Delete
                if (Collection["btnSubmit"] == "delete")
                {
                    Product.Delete();
                    return(RedirectToAction("MyProducts"));
                }
                if (Collection["btnSubmit"] == "save")
                {
                    Product.Title       = (string)Collection["ProductList[0].Title"];
                    Product.Price       = Convert.ToInt64(Collection["ProductList[0].Price"]);
                    Product.CategoryID  = (Models.ProductTypes)Enum.Parse(typeof(Models.ProductTypes), Collection["ProductList[0].CategoryID"].ToString());
                    Product.Description = (string)Collection["ProductList[0].Description"];
                    Product.StatusID    = Models.StatusTypes.Active;

                    Product.Save();

                    if (PrimaryImage != null)
                    {
                        Product.PrimaryImage               = new Models.CImage();
                        Product.PrimaryImage.FileName      = System.IO.Path.GetFileName(PrimaryImage.FileName);
                        Product.PrimaryImage.FileExtension = System.IO.Path.GetExtension(Product.PrimaryImage.FileName);
                        if (Product.PrimaryImage.IsImageFile())
                        {
                            Product.PrimaryImage.FileSize = PrimaryImage.ContentLength;
                            Stream       stream       = PrimaryImage.InputStream;
                            BinaryReader binaryReader = new BinaryReader(stream);
                            Product.PrimaryImage.FileBytes = binaryReader.ReadBytes((int)stream.Length);

                            // If the product already has an image
                            if (db.HasPrimaryImage(Product.ProductID) == true)
                            {
                                // Edit the existing one
                                Product.UpdatePrimaryImage();
                            }
                            else
                            {
                                // Otherwise, add an image
                                Product.AddPrimaryImage();
                            }
                        }
                        else
                        {
                            Product.PrimaryImage = null;
                        }
                    }
                }
                return(RedirectToAction("MyProducts"));
            }
            catch (Exception)
            {
                return(null);
            }
        }
Пример #12
0
 public ActionResult MyProfile()
 {
     Models.CUser User = new Models.CUser();
     User = User.GetCurrentUser();
     return(View(User));
 }
Пример #13
0
 public ActionResult Payment()
 {
     Models.CUser User = new Models.CUser();
     User = User.GetCurrentUser();
     return(View(User));
 }