public ActionResult Login(ChanchosUser au) { //connect to database //databaseChanchosEntities _dbContext = new databaseChanchosEntities(); //compare CU vs chanchosUser Table //ChanchosUser match = (from a in _dbContext.ChanchosUsers // where (a.name == CU.name && a.passwords == a.passwords) // select a).SingleOrDefault(); //check existent databaseChanchosEntities db = new databaseChanchosEntities(); var match = (from x in db.ChanchosUsers where (x.name == au.name && x.passwords == au.passwords) select x).SingleOrDefault(); if (match == null) { ViewBag.errMessage = "Invalid Login"; return(View()); } else { FormsAuthentication.SetAuthCookie(au.name, false); return(RedirectToAction("Index", "Home")); } }
public ActionResult Index() { databaseChanchosEntities db = new databaseChanchosEntities(); var productList = db.Products.ToList(); var pList = db.Products.ToList(); return(View(pList)); }
public override string[] GetRolesForUser(string username) { //connect with database databaseChanchosEntities _dbContext = new databaseChanchosEntities(); string s = _dbContext.ChanchosUsers.Where(x => x.name == username).FirstOrDefault().roles; string[] result = { s }; return(result); }
public ActionResult Index() { //for user management databaseChanchosEntities db = new databaseChanchosEntities(); var userList = db.ChanchosUsers.ToList(); var uList = db.ChanchosUsers.ToList(); return(View(uList)); }
public ActionResult addProduct(Product p) { string fileName = Path.GetFileNameWithoutExtension(p.ImageFile.FileName); string extension = Path.GetExtension(p.ImageFile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; p.ProductImage = "~/image/" + fileName; fileName = Path.Combine(Server.MapPath("~/image/"), fileName); p.ImageFile.SaveAs(fileName); using (databaseChanchosEntities dl = new databaseChanchosEntities()) { dl.Products.Add(p); dl.SaveChanges(); } ModelState.Clear(); // databaseChanchosEntities dbContext = new databaseChanchosEntities(); //dbContext.Products.Add(p); //dbContext.SaveChanges(); return(View()); }