public ActionResult Create([Bind(Include = "adminID, adminName, email, password, confirmPassword")] Admin admin)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Admin admins = new Admin();
                    admins.adminName       = admin.adminName;
                    admins.email           = admin.email;
                    admins.password        = Cipher.Encrypt(admin.password);
                    admins.confirmPassword = Cipher.Encrypt(admin.confirmPassword);

                    BuyalotDbContext Context = new BuyalotDbContext();
                    Context.Admins.Add(admins);
                    Context.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException /*dex*/)
            {
                //Log the error (uncomment dex variable name after DataException and add a line here to write a log.)
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, contact your system administrator.");
            }
            return(View(admin));
        }
Exemple #2
0
        public ActionResult Index(string searchString)
        {
            var db = new BuyalotDbContext();

            var product = (from p in db.Products
                           where p.QuantityInStock > 0
                           join pc in db.ProductCategories
                           on p.ProdCategoryID equals pc.ProdCategoryID
                           select new ProductCatViewModel
            {
                productImage = p.ProductImage,
                productID = p.ProductID,
                price = p.Price,
                productName = p.ProductName,
                vendor = p.Vendor,
                quantityInStock = p.QuantityInStock,
                productDescription = p.ProductDescription,
                categoryName = pc.CategoryName
            });


            if (!String.IsNullOrEmpty(searchString))
            {
                product = product.Where(s => s.productName.StartsWith(searchString) ||
                                        s.productName.Contains(searchString) ||
                                        s.vendor.StartsWith(searchString) ||
                                        s.productDescription.StartsWith(searchString) ||
                                        s.productDescription.Contains(searchString) ||
                                        s.vendor.Contains(searchString) ||
                                        s.categoryName.Contains(searchString) ||
                                        s.categoryName.StartsWith(searchString)
                                        );
            }

            ViewBag.ProductList = db.Products.ToList();
            return(View(product));
        }
 public GenericRepository(BuyalotDbContext context)
 {
     this.context = context;
     this.dbSet   = context.Set <TEntity>();
 }
Exemple #4
0
 public CustomerAccountController()
 {
     Context         = new BuyalotDbContext();
     _DisposeContext = true;
 }
Exemple #5
0
 public HomeController()
 {
     Context         = new BuyalotDbContext();
     _DisposeContext = true;
 }
 public AdminAccountController()
 {
     Context         = new BuyalotDbContext();
     _DisposeContext = true;
 }