Example #1
0
        public ActionResult Minus_To_Cart(int id)
        {
            //Console.WriteLine("Add to shoppingcart is succesfully called");
            int?ProductId;

            ProductId = id;


            using (new_testEntities db = new new_testEntities())
            {
                //user user = db.user.FirstOrDefault(x => x.ID == id);
                shoppingcart Shoppingcart = db.shoppingcart.FirstOrDefault(x => x.ProductId == id);


                Shoppingcart.Quantity -= 1;
                db.SaveChanges();

                if (Shoppingcart.Quantity <= 0)
                {
                    db.shoppingcart.Remove(Shoppingcart);
                    db.SaveChanges();
                }


                return(RedirectToAction("Index", "Shoppingcart"));
            }
        }
Example #2
0
        public ActionResult CheckOut()
        {
            List <shoppingcart> shoppingcartitems = new List <shoppingcart>();
            product             product           = new product();
            EmailService        mail    = new EmailService();
            IdentityMessage     message = new IdentityMessage();
            var keys = Request.Form.AllKeys;

            message.Destination = Request.Form.Get(keys[0]);
            message.Subject     = "Order confirmation Bright Yellow";
            message.Body        = "Thank you for your purchase. <br />You purchased the following items:";
            using (new_testEntities db = new new_testEntities())
            {
                string userid = "0";
                if (Request.IsAuthenticated)
                {
                    userid = User.Identity.GetUserId();
                }
                shoppingcartitems = db.shoppingcart.Where(x => x.UserId == userid).ToList();

                foreach (shoppingcart item in shoppingcartitems)
                {
                    product       = db.product.FirstOrDefault(x => x.ID == item.ProductId);
                    product.stock = product.stock - item.Quantity;
                    message.Body  = message.Body + "<br />" + product.ProductName;
                    if (product.PurchasedQuantity == null)
                    {
                        product.PurchasedQuantity = 1;
                    }
                    product.PurchasedQuantity = product.PurchasedQuantity + item.Quantity;
                    db.SaveChanges();
                    db.shoppingcart.Remove(item);
                    db.SaveChanges();
                    int             productid   = item.ProductId;
                    int             quantity    = (int)item.Quantity;
                    DateTime        date        = DateTime.Now;
                    string          productname = product.ProductName;
                    string          imagePath   = product.imagepath;
                    purchasehistory ph          = new purchasehistory
                    {
                        ProductID    = productid,
                        UserID       = userid,
                        Quantity     = quantity,
                        PurchaseDate = date,
                        ProductName  = productname,
                        imagepath    = imagePath
                    };
                    db.purchasehistory.Add(ph);
                    db.SaveChanges();
                }
                try
                {
                    mail.SendAsync(message);
                }
                catch
                {
                }
            }
            return(View());
        }
Example #3
0
 public ActionResult Index()
 {
     using (new_testEntities db = new new_testEntities())
     {
         return(View(db.ssd.ToList()));
     }
 }
Example #4
0
 public ActionResult Index()
 {
     using (new_testEntities db = new new_testEntities())
     {
         return(View(db.internalharddisk.ToList()));
     }
 }
Example #5
0
        public ActionResult View(int id)
        {
            ssd ssdimage = new ssd();

            using (new_testEntities db = new new_testEntities())
            {
                //db.ram.Add(new ram
                //{
                //    Brand = "testbrand",
                //    CompositionOfMemory = "wut",
                //    MemoryType = "testtype",
                //    Clockspeed = 1,
                //    CASlatency = 1,
                //    Voltage = 1,
                //    MemoryModuleConnection = 50,
                //    MemorySuitableFor = "datatest",
                //    ImagePath = "C:/Users/Erik/Desktop/Prj5-6/project-5-6 - Copy/webshop2/webshop2/Contentram1.jpg"
                //});

                //db.SaveChanges();

                ssdimage = db.ssd.Where(x => x.ID == id).FirstOrDefault();
            }
            return(View(ssdimage));
        }
Example #6
0
        //[HttpGet]
        public ActionResult Add_To_Wishlist(int id)
        {
            //Console.WriteLine("Add to wishlist is succesfully called");
            ID = id;


            using (new_testEntities db = new new_testEntities())
            {
                //user user = db.user.FirstOrDefault(x => x.ID == id);
                product  product  = db.product.FirstOrDefault(x => x.ID == id);
                string   userid   = User.Identity.GetUserId();
                wishlist Wishlist = db.wishlist.FirstOrDefault(x => x.ProductId == id && x.UserId == userid);

                if (Wishlist == null)
                {
                    db.wishlist.Add(new wishlist {
                        ProductId = product.ID, UserId = userid, Quantity = 1, ProductName = product.ProductName, Price = product.price, Imagepath = product.imagepath
                    });
                    db.SaveChanges();
                }
                else
                {
                    Wishlist.Quantity += 1;
                    db.SaveChanges();
                }

                return(RedirectToAction("Index", "Wishlist"));
            }
        }
Example #7
0
        public ActionResult Minus_To_Wishlist(int id)
        {
            //Console.WriteLine("Add to wishlist is succesfully called");
            int?ProductId;

            ProductId = id;


            using (new_testEntities db = new new_testEntities())
            {
                //user user = db.user.FirstOrDefault(x => x.ID == id);
                wishlist Wishlist = db.wishlist.FirstOrDefault(x => x.ProductId == id);


                Wishlist.Quantity -= 1;
                db.SaveChanges();

                if (Wishlist.Quantity <= 0)
                {
                    db.wishlist.Remove(Wishlist);
                    db.SaveChanges();
                }


                return(RedirectToAction("Index", "Wishlist"));
            }
        }
Example #8
0
        public ActionResult Add_To_Cart(int id)
        {
            //Console.WriteLine("Add to wishlist is succesfully called");
            int?ProductId;

            ProductId = id;


            using (new_testEntities db = new new_testEntities())
            {
                product product = db.product.FirstOrDefault(x => x.ID == id);
                string  userid  = "0";
                if (Request.IsAuthenticated)
                {
                    userid = User.Identity.GetUserId();
                }
                shoppingcart shoppingcart = db.shoppingcart.FirstOrDefault(x => x.ProductId == id && x.UserId == userid);
                wishlist     Wishlist     = db.wishlist.FirstOrDefault(x => x.ProductId == id);

                if (shoppingcart == null)
                {
                    db.shoppingcart.Add(new shoppingcart {
                        ProductId = Wishlist.ProductId, UserId = User.Identity.GetUserId(), Quantity = Wishlist.Quantity, ProductName = Wishlist.ProductName, Price = Wishlist.Price, Imagepath = Wishlist.Imagepath
                    });
                    db.SaveChanges();
                }
                else
                {
                    shoppingcart.Quantity += Wishlist.Quantity;
                    db.SaveChanges();
                }

                return(RedirectToAction("Index", "Shoppingcart"));
            }
        }
Example #9
0
 public ActionResult FilterRam(string searchstring)
 {
     using (new_testEntities db = new new_testEntities())
     {
         var data = db.ram.Where(r => r.Name.Contains(searchstring) || r.Brand.Contains(searchstring) || r.MemorySuitableFor.Contains(searchstring) || r.MemoryType.Contains(searchstring)).ToList();
         return(View(data));
     }
 }
Example #10
0
        // GET: Statistics/Details/5
        public ActionResult Details(int id)
        {
            ram ram = new ram();

            using (new_testEntities db = new new_testEntities())
            {
                ram = db.ram.FirstOrDefault(x => x.ID == id);
            }
            return(View(ram));
        }
Example #11
0
        public ActionResult View(int id)
        {
            wishlist wishlist = new wishlist();

            using (new_testEntities db = new new_testEntities())
            {
                wishlist = db.wishlist.FirstOrDefault(x => x.ProductId == 1);
            }

            return(View(wishlist));
        }
Example #12
0
        public ActionResult Delete(int id)
        {
            using (new_testEntities db = new new_testEntities())
            {
                shoppingcart shoppingcart = db.shoppingcart.FirstOrDefault(x => x.ProductId == id);
                db.shoppingcart.Remove(shoppingcart);
                db.SaveChanges();
            }

            return(RedirectToAction("Index", "Shoppingcart"));
        }
Example #13
0
        public ActionResult Index() //laten zien van de wishlist
        {
            List <wishlist> list_wishlist = new List <wishlist>();

            using (new_testEntities db = new new_testEntities())
            {
                using (ApplicationDbContext db2 = new ApplicationDbContext())
                {
                    string userid = User.Identity.GetUserId();
                    return(View(db.wishlist.Where(item => item.UserId == userid).ToList()));
                }
            }
        }
Example #14
0
 public ActionResult Create(FormCollection collection)
 {
     try
     {
         using (ApplicationDbContext db2 = new ApplicationDbContext())
         {
             if (User.IsInRole("Admin"))
             {
                 // TODO: Add insert logic here
                 using (new_testEntities db = new new_testEntities())
                 {
                     product p = new product
                     {
                         price       = Convert.ToDecimal(collection[11]),
                         imagepath   = collection[9],
                         stock       = 100,
                         Brand       = collection[1],
                         Supplier    = "testsupplier",
                         ProductName = collection[10]
                     };
                     ram r = new ram
                     {
                         ID    = p.ID,
                         Brand = p.Brand,
                         CompositionOfMemory    = collection[2],
                         MemoryType             = collection[3],
                         Clockspeed             = Convert.ToInt32(collection[4]),
                         CASlatency             = Convert.ToInt32(collection[5]),
                         Voltage                = (float)Convert.ToDouble(collection[6]),
                         MemoryModuleConnection = Convert.ToInt32(collection[7]),
                         MemorySuitableFor      = collection[8],
                         ImagePath              = p.imagepath,
                         Name    = p.ProductName,
                         Price   = p.price,
                         Ramsize = Convert.ToInt32(collection[12])
                     };
                     db.product.Add(p);
                     db.ram.Add(r);
                     db.SaveChanges();
                 }
             }
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Example #15
0
 // GET: Statistics/Edit/5
 public ActionResult Edit(int id)
 {
     using (ApplicationDbContext db2 = new ApplicationDbContext())
     {
         ram ram = new ram();
         if (User.IsInRole("Admin"))
         {
             using (new_testEntities db = new new_testEntities())
             {
                 ram = db.ram.FirstOrDefault(r => r.ID == id);
             }
         }
         return(View(ram));
     }
 }
Example #16
0
        // GET: Shoppingcart
        public ActionResult Index()
        {
            if (Request.HttpMethod == "POST")
            {
                return(CheckOut());
            }
            else
            {
                ViewBag.Message = "Your Shopping Cart.";
                List <shoppingcart> listshoppingcartitems = new List <shoppingcart>();
                using (new_testEntities db = new new_testEntities())
                {
                    string userid = "0";
                    if (Request.IsAuthenticated)
                    {
                        userid = User.Identity.GetUserId();
                    }
                    listshoppingcartitems = db.shoppingcart.Where(x => x.UserId == userid).ToList();
                    if (listshoppingcartitems.Count > 0)
                    {
                        int     totalquantity = 0;
                        decimal totalprice    = 0;
                        foreach (var item in listshoppingcartitems)
                        {
                            totalquantity += (int)item.Quantity;
                            totalprice    += (decimal)item.Price * (int)item.Quantity;
                        }
                        listshoppingcartitems.Add(
                            new shoppingcart
                        {
                            Quantity    = totalquantity,
                            Price       = totalprice,
                            ProductName = " ",
                            Imagepath   = " "
                        });
                    }
                    if (Request.IsAuthenticated && listshoppingcartitems.Count > 0)
                    {
                        using (ApplicationDbContext db2 = new ApplicationDbContext())
                        {
                            listshoppingcartitems[0].email = db2.Users.FirstOrDefault(user => user.Id == userid).Email;
                        }
                    }
                }

                return(View(listshoppingcartitems));
            }
        }
Example #17
0
 // GET: Statistics/Delete/5
 public ActionResult Delete(int id)
 {
     using (ApplicationDbContext db2 = new ApplicationDbContext())
     {
         if (User.IsInRole("Admin"))
         {
             using (new_testEntities db = new new_testEntities())
             {
                 ram     ram     = db.ram.FirstOrDefault(r => r.ID == id);
                 product product = db.product.FirstOrDefault(p => p.ID == id);
                 db.ram.Remove(ram);
                 db.product.Remove(product);
                 db.SaveChanges();
             }
         }
     }
     return(RedirectToAction("Index"));
 }
Example #18
0
        // GET: Statistics
        public ActionResult Index()
        {
            List <product> listproducts = new List <product>();


            using (ApplicationDbContext db2 = new ApplicationDbContext())
            {
                if (User.IsInRole("Admin"))
                {
                    using (new_testEntities db = new new_testEntities())
                    {
                        listproducts = db.product.ToList();
                    }
                }
            }

            return(View(listproducts));
        }
Example #19
0
 // GET: purchasehistory
 public ActionResult Index()
 {
     using (new_testEntities db = new new_testEntities())
     {
         using (ApplicationDbContext db2 = new ApplicationDbContext())
         {
             string userID = User.Identity.GetUserId();
             if (User.IsInRole("Admin"))
             {
                 return(View(db.purchasehistory.ToList()));
             }
             else
             {
                 return(View(db.purchasehistory.Where(ph => ph.UserID == userID).ToList()));
             }
         }
     }
 }
Example #20
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                using (ApplicationDbContext db2 = new ApplicationDbContext())
                {
                    if (User.IsInRole("Admin"))
                    {
                        using (new_testEntities db = new new_testEntities())
                        {
                            // TODO: Add update logic here
                            ram     ram     = db.ram.FirstOrDefault(r => r.ID == id);
                            product product = db.product.FirstOrDefault(p => p.ID == id);
                            ram.ImagePath              = collection[10];
                            product.imagepath          = collection[10];
                            ram.Brand                  = collection[2];
                            product.Brand              = collection[2];
                            ram.CompositionOfMemory    = collection[3];
                            ram.MemoryType             = collection[4];
                            ram.Clockspeed             = Convert.ToInt32(collection[5]);
                            ram.CASlatency             = Convert.ToInt32(collection[6]);
                            ram.Voltage                = (float)Convert.ToDouble(collection[7]);
                            ram.MemoryModuleConnection = Convert.ToInt32(collection[8]);
                            ram.MemorySuitableFor      = collection[9];
                            ram.Name            = collection[11];
                            product.ProductName = collection[11];
                            ram.Price           = Convert.ToDecimal(collection[12]);
                            product.price       = Convert.ToDecimal(collection[12]);
                            ram.Ramsize         = Convert.ToInt32(collection[13]);

                            db.SaveChanges();
                        }
                    }
                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                return(View());
            }
        }
Example #21
0
        public ActionResult View(int?id)
        {
            ram ram = new ram();

            ID = id;
            using (new_testEntities db = new new_testEntities())
            {
                //db.product.Add(new product
                //{
                //    ID = id,
                //    price = 80,
                //    imagepath = "~/images/ram/ram1.jpg",
                //    stock = 100,
                //    Brand = "Kingston",
                //    Supplier = "testsupplier"
                //});
                //db.SaveChanges();
                //product product = db.product.FirstOrDefault(x => x.ID == id);
                //db.ram.Add(new ram
                //{
                //    ID = product.ID,
                //    Brand = "Kingston",
                //    CompositionOfMemory = "1x",
                //    MemoryType = "DDR3",
                //    Clockspeed = 2133,
                //    CASlatency = 15,
                //    Voltage = (float)1.2 ,
                //    MemoryModuleConnection = 1,
                //    MemorySuitableFor = "Desktop",
                //    ImagePath = "~/images/ram/ram1.jpg",
                //    Name = "Kingston123",
                //    Price = 80,
                //    Ramsize = 8
                //});

                //db.SaveChanges();

                ram = db.ram.Where(x => x.ID == ID).FirstOrDefault();
            }
            return(View(ram));
        }
Example #22
0
        public ActionResult ShowChart()
        {
            using (new_testEntities db = new new_testEntities())
            {
                List <string> listproductnames             = new List <string>();
                List <string> listproductpurchasedquantity = new List <string>();
                foreach (product p in db.product)
                {
                    if (p.PurchasedQuantity > 0)
                    {
                        listproductnames.Add(p.ProductName.ToString());
                        listproductpurchasedquantity.Add(p.PurchasedQuantity.ToString());
                    }
                }
                var chart = new Chart(width: 600, height: 400)
                            .AddSeries(
                    chartType: "column",
                    xValue: listproductnames,
                    yValues: listproductpurchasedquantity)
                            .GetBytes("png");

                return(File(chart, "image/bytes"));
            }
        }
Example #23
0
 public ActionResult FilterRam(int?minprice, int?maxprice, int?minsize, int?maxsize, string brands, string ramType)
 {
     using (new_testEntities db = new new_testEntities())
     {
         if (ramType == "")
         {
             if (brands == "")
             {
                 if (minprice == null)
                 {
                     if (maxprice == null)
                     {
                         if (minsize == null)
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Ramsize <= maxsize).ToList()));
                             }
                         }
                         else
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Ramsize >= minsize).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Ramsize >= minsize && r.Ramsize <= maxsize).ToList()));
                             }
                         }
                     }
                     else
                     {
                         if (minsize == null)
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price <= maxprice).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price <= maxprice && r.Ramsize <= maxsize).ToList()));
                             }
                         }
                         else
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price <= maxprice && r.Ramsize >= minsize).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price <= maxprice && r.Ramsize >= minsize && r.Ramsize <= maxsize).ToList()));
                             }
                         }
                     }
                 }
                 else
                 {
                     if (maxprice == null)
                     {
                         if (minsize == null)
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Ramsize <= maxsize).ToList()));
                             }
                         }
                         else
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Ramsize >= minsize).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Ramsize >= minsize && r.Ramsize <= maxsize).ToList()));
                             }
                         }
                     }
                     else
                     {
                         if (minsize == null)
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Price <= maxprice).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Price <= maxprice && r.Ramsize <= maxsize).ToList()));
                             }
                         }
                         else
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Price <= maxprice && r.Ramsize >= minsize).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Price <= maxprice && r.Ramsize >= minsize && r.Ramsize <= maxsize).ToList()));
                             }
                         }
                     }
                 }
             }
             else
             {
                 if (minprice == null)
                 {
                     if (maxprice == null)
                     {
                         if (minsize == null)
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Brand == brands).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Ramsize <= maxsize && r.Brand == brands).ToList()));
                             }
                         }
                         else
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Ramsize >= minsize && r.Brand == brands).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Ramsize >= minsize && r.Ramsize <= maxsize && r.Brand == brands).ToList()));
                             }
                         }
                     }
                     else
                     {
                         if (minsize == null)
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price <= maxprice && r.Brand == brands).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price <= maxprice && r.Ramsize <= maxsize && r.Brand == brands).ToList()));
                             }
                         }
                         else
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price <= maxprice && r.Ramsize >= minsize && r.Brand == brands).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price <= maxprice && r.Ramsize >= minsize && r.Ramsize <= maxsize && r.Brand == brands).ToList()));
                             }
                         }
                     }
                 }
                 else
                 {
                     if (maxprice == null)
                     {
                         if (minsize == null)
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Brand == brands).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Ramsize <= maxsize && r.Brand == brands).ToList()));
                             }
                         }
                         else
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Ramsize >= minsize && r.Brand == brands).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Ramsize >= minsize && r.Ramsize <= maxsize && r.Brand == brands).ToList()));
                             }
                         }
                     }
                     else
                     {
                         if (minsize == null)
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Price <= maxprice && r.Brand == brands).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Price <= maxprice && r.Ramsize <= maxsize && r.Brand == brands).ToList()));
                             }
                         }
                         else
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Price <= maxprice && r.Ramsize >= minsize && r.Brand == brands).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Price <= maxprice && r.Ramsize >= minsize && r.Ramsize <= maxsize && r.Brand == brands).ToList()));
                             }
                         }
                     }
                 }
             }
         }
         else
         {
             if (brands == "")
             {
                 if (minprice == null)
                 {
                     if (maxprice == null)
                     {
                         if (minsize == null)
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.MemoryType == ramType).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Ramsize <= maxsize && r.MemoryType == ramType).ToList()));
                             }
                         }
                         else
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Ramsize >= minsize && r.MemoryType == ramType).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Ramsize >= minsize && r.Ramsize <= maxsize && r.MemoryType == ramType).ToList()));
                             }
                         }
                     }
                     else
                     {
                         if (minsize == null)
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price <= maxprice && r.MemoryType == ramType).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price <= maxprice && r.Ramsize <= maxsize && r.MemoryType == ramType).ToList()));
                             }
                         }
                         else
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price <= maxprice && r.Ramsize >= minsize && r.MemoryType == ramType).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price <= maxprice && r.Ramsize >= minsize && r.Ramsize <= maxsize && r.MemoryType == ramType).ToList()));
                             }
                         }
                     }
                 }
                 else
                 {
                     if (maxprice == null)
                     {
                         if (minsize == null)
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.MemoryType == ramType).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Ramsize <= maxsize && r.MemoryType == ramType).ToList()));
                             }
                         }
                         else
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Ramsize >= minsize && r.MemoryType == ramType).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Ramsize >= minsize && r.Ramsize <= maxsize && r.MemoryType == ramType).ToList()));
                             }
                         }
                     }
                     else
                     {
                         if (minsize == null)
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Price <= maxprice && r.MemoryType == ramType).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Price <= maxprice && r.Ramsize <= maxsize && r.MemoryType == ramType).ToList()));
                             }
                         }
                         else
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Price <= maxprice && r.Ramsize >= minsize && r.MemoryType == ramType).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Price <= maxprice && r.Ramsize >= minsize && r.Ramsize <= maxsize && r.MemoryType == ramType).ToList()));
                             }
                         }
                     }
                 }
             }
             else
             {
                 if (minprice == null)
                 {
                     if (maxprice == null)
                     {
                         if (minsize == null)
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Brand == brands && r.MemoryType == ramType).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Ramsize <= maxsize && r.Brand == brands && r.MemoryType == ramType).ToList()));
                             }
                         }
                         else
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Ramsize >= minsize && r.Brand == brands && r.MemoryType == ramType).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Ramsize >= minsize && r.Ramsize <= maxsize && r.Brand == brands && r.MemoryType == ramType).ToList()));
                             }
                         }
                     }
                     else
                     {
                         if (minsize == null)
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price <= maxprice && r.Brand == brands && r.MemoryType == ramType).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price <= maxprice && r.Ramsize <= maxsize && r.Brand == brands && r.MemoryType == ramType).ToList()));
                             }
                         }
                         else
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price <= maxprice && r.Ramsize >= minsize && r.Brand == brands && r.MemoryType == ramType).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price <= maxprice && r.Ramsize >= minsize && r.Ramsize <= maxsize && r.Brand == brands && r.MemoryType == ramType).ToList()));
                             }
                         }
                     }
                 }
                 else
                 {
                     if (maxprice == null)
                     {
                         if (minsize == null)
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Brand == brands && r.MemoryType == ramType).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Ramsize <= maxsize && r.Brand == brands && r.MemoryType == ramType).ToList()));
                             }
                         }
                         else
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Ramsize >= minsize && r.Brand == brands && r.MemoryType == ramType).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Ramsize >= minsize && r.Ramsize <= maxsize && r.Brand == brands && r.MemoryType == ramType).ToList()));
                             }
                         }
                     }
                     else
                     {
                         if (minsize == null)
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Price <= maxprice && r.Brand == brands && r.MemoryType == ramType).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Price <= maxprice && r.Ramsize <= maxsize && r.Brand == brands && r.MemoryType == ramType).ToList()));
                             }
                         }
                         else
                         {
                             if (maxsize == null)
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Price <= maxprice && r.Ramsize >= minsize && r.Brand == brands && r.MemoryType == ramType).ToList()));
                             }
                             else
                             {
                                 return(View(db.ram.Where(r => r.Price >= minprice && r.Price <= maxprice && r.Ramsize >= minsize && r.Ramsize <= maxsize && r.Brand == brands && r.MemoryType == ramType).ToList()));
                             }
                         }
                     }
                 }
             }
         }
     }
 }