public ActionResult EditAccountSubmit(User user) { if (!ModelState.IsValid) { return(View("EditAccount", user)); } User _user = new User(); using (var db = new App_Context()) { _user = db.Users.SingleOrDefault(i => i.Username == user.Username); if (_user != null) { _user.Username = user.Username; _user.Password = user.Password; _user.Salt = user.Salt; _user.Email = user.Email; _user.City = user.City; _user.Firstname = user.Firstname; _user.Lastname = user.Lastname; _user.Phone = user.Phone; _user.RoleId = user.RoleId; _user.Address = user.Address; db.SaveChanges(); } } return(RedirectToAction("Index", "Home")); }
public ActionResult CustOrders(string name) { List <OrdersJoin> customerOrders = new List <OrdersJoin>(); using (App_Context db = new App_Context()) { int userId = db.Users.Where(n => n.Username == name).Select(i => i.UserId).FirstOrDefault(); //customerOrders = db.Orders.Where(c => c.UserId == userId).OrderByDescending(c => c.OrderDate).ToList(); customerOrders = (from ord in db.Orders join ordDet in db.OrderDetails on ord.OrderId equals ordDet.OrderId join prod in db.Products on ordDet.ProductId equals prod.ProductId where ord.Username == name select new OrdersJoin { State = ord.OrderState, OrderDate = ord.OrderDate, Quantity = ordDet.Quantity, ProductPrice = ordDet.ProductPrice, ProductName = prod.ProductName }).ToList(); Session["CustomDet"] = userId; //if (name != db.Users.) } return(View(customerOrders)); }
public ActionResult EditSubmitUser(User user) { if (!ModelState.IsValid) { return(View("EditUser", user)); } User dUser = new User(); using (App_Context db = new App_Context()) { dUser = db.Users.SingleOrDefault(d => d.UserId == user.UserId); if (dUser == null) { return(HttpNotFound()); } else { dUser.Password = user.Password; dUser.Firstname = user.Firstname; dUser.Lastname = user.Lastname; dUser.Address = user.Address; dUser.PostalCode = user.PostalCode; dUser.City = user.City; dUser.Email = user.Email; dUser.Phone = user.Phone; dUser.Salt = user.Salt; db.SaveChanges(); } return(RedirectToAction("Dashboard", "Admin")); } }
public ActionResult ChangeRole(int id) { User assignedUser = new User(); Role assignedRole = new Role(); using (App_Context db = new App_Context()) { assignedUser = db.Users.Include("Role").SingleOrDefault(b => b.UserId == id); if (assignedUser == null) { return(HttpNotFound()); } if (assignedUser.Role.Rolename == "Admin") { assignedRole = db.Roles.Find(2); } if (assignedUser.Role.Rolename == "User") { assignedRole = db.Roles.Find(1); } assignedUser.Role = assignedRole; db.SaveChanges(); } return(RedirectToAction("Dashboard", "Admin")); }
//Λιστα με όλους τους μπαναρισμένους users public ActionResult BannedUsers() { using (App_Context db = new App_Context()) { List <User> allBannedUsers = db.Users.Where(b => b.Role.RoleId == 3).ToList(); return(View(allBannedUsers)); } }
public ActionResult ProductByCat(int id) { using (var db = new App_Context()) { var allProducts = db.Products.Where(i => i.Category.CategoryId == id).ToList(); product = allProducts; } return(View(product)); }
public List <User> GetAllUsers() { List <User> allUsers; using (App_Context db = new App_Context()) { allUsers = db.Users.Include("Role").ToList(); } return(allUsers); }
public ActionResult EditAccount(string name) { User user; using (var db = new App_Context()) { user = db.Users.Where(i => i.Username == name).SingleOrDefault(); } return(View(user)); }
//Eπιστρέφει όλες τις κατηγορίες σε λίστα public ActionResult Categories() { List <Category> allCategories = new List <Category>(); using (App_Context db = new App_Context()) { allCategories = db.Categories.ToList(); } return(View(allCategories)); }
public ActionResult Dashboard() { List <User> users = new List <User>(); using (App_Context db = new App_Context()) { users = db.Users.ToList(); } return(View(users)); }
public ActionResult ReturnUsers() { List <User> users = new List <User>(); using (App_Context db = new App_Context()) { users = db.Users.ToList(); } //var vm = new GlobalModel(); return(View(users)); }
public ActionResult DailyDishes() { Random r = new Random(); List <Product> allDishes; using (var db = new App_Context()) { allDishes = db.Products.Where(i => i.Category.CategoryId == 2).Take(3).ToList(); } return(View(allDishes)); }
//Ζητάει το id του χρήστη και τις νέες τιμές και καταχωρεί τις αλλαγές στη βάση public ActionResult EditUser(int id) { User editedUser = new User(); using (App_Context db = new App_Context()) { editedUser = db.Users.SingleOrDefault(u => u.UserId == id); } if (editedUser == null) { return(HttpNotFound()); } return(View(editedUser)); }
//Zητάει το id του χρήστη και φέρνει πίσω όλα τα στοιχεία του λεπτομερώς //Πιθανή χρήση σε button "Details" κάτω από κάθε χρήστη public ActionResult UserDetails(int id) { User detailedUser = new User(); using (App_Context db = new App_Context()) { detailedUser = db.Users.Include("Role").SingleOrDefault(u => u.UserId == id); } if (detailedUser == null) { return(HttpNotFound()); } return(View(detailedUser)); }