public ActionResult Create(Order order, Item item, Request request) { if (ModelState.IsValid) { order.DateMade = DateTime.Now; db.Orders.Add(order); db.Items.Add(item); db.Requests.Add(request); db.SaveChanges(); db.Items.Remove(item); db.SaveChanges(); return(RedirectToAction("CreateWithVendor")); } var roleManager = new Microsoft.AspNet.Identity.RoleManager <IdentityRole>(new RoleStore <IdentityRole>(new ApplicationDbContext())); string Supervisor = roleManager.FindByName("Supervisor").Id; ViewBag.StatusID = new SelectList(db.Statuses.Where(s => s.StatusName == "Pending"), "Id", "StatusName"); ViewBag.BudgetCodeID = new SelectList(db.BudgetCodes, "Id", "BudgetCodeName"); ViewBag.EmployeeID = new SelectList(db.Users.Where(i => i.Email.Equals(HttpContext.User.Identity.Name.ToString())), "ID", "Email"); ViewBag.SupervisorID = new SelectList(db.Users.Where(u => u.Roles.Any(r => r.RoleId == Supervisor)).ToList(), "ID", "Email"); return(View(request)); }
// GET: Divisions/Create public ActionResult CreateDivisionWithSupervisor() { var roleManager = new Microsoft.AspNet.Identity.RoleManager <IdentityRole>(new RoleStore <IdentityRole>(new ApplicationDbContext())); string Supervisor = roleManager.FindByName("Supervisor").Id; ViewBag.SupervisorID = new SelectList(db.Users.Where(u => u.Roles.Any(r => r.RoleId == Supervisor)).ToList(), "ID", "Email"); return(View()); }
public ActionResult CreateDivisionWithSupervisor(Division division) { if (ModelState.IsValid) { db.Divisions.Add(division); db.SaveChanges(); return(RedirectToAction("Index")); } var roleManager = new Microsoft.AspNet.Identity.RoleManager <IdentityRole>(new RoleStore <IdentityRole>(new ApplicationDbContext())); string Supervisor = roleManager.FindByName("Supervisor").Id; ViewBag.SupervisorID = new SelectList(db.Users.Where(u => u.Roles.Any(r => r.RoleId == Supervisor)).ToList(), "ID", "Email"); return(View(division)); }
public ActionResult Create() { var roleManager = new Microsoft.AspNet.Identity.RoleManager <IdentityRole>(new RoleStore <IdentityRole>(new ApplicationDbContext())); string Supervisor = roleManager.FindByName("Supervisor").Id; ViewBag.EmployeeID = new SelectList(db.Users.Where(i => i.Email.Equals(HttpContext.User.Identity.Name.ToString())), "ID", "Email"); ViewBag.SupervisorID = new SelectList(db.Employees.Where(u => u.Roles.Any(r => r.RoleId == Supervisor && u.Department.DepartmentName.Equals("STEM"))).ToList(), "ID", "Email"); ViewBag.BudgetCodeID = new SelectList(db.BudgetCodes, "Id", "BudgetCodeName"); ViewBag.StatusID = new SelectList(db.Statuses.Where(s => s.StatusName == "Pending"), "Id", "StatusName"); ViewBag.CategoryID = new SelectList(db.Categories, "Id", "CategoryName"); return(View()); }