//GET: ProjectSupervisors/Edit/5 public ActionResult Select(string id, string StudentNumber) { string studID = StudentNumber; using (var db = new ProgressTrackerEntities()) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProjectSupervisor supervisor = db.ProjectSupervisors.Find(id); Student student = db.Students.Find(id); if (supervisor == null) { return(HttpNotFound()); } string selectedSup = supervisor.UserID; Allocation allocation = new Allocation(); allocation.StaffNumber = id; allocation.StudentNumber = studID; db.Allocations.Add(allocation); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } }
public ActionResult DeleteConfirmed(string id) { ProjectSupervisor projectSupervisor = db.ProjectSupervisors.Find(id); db.ProjectSupervisors.Remove(projectSupervisor); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "StaffNumber,calId")] ProjectSupervisor projectSupervisor) { if (ModelState.IsValid) { db.Entry(projectSupervisor).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StaffNumber = new SelectList(db.AspNetUsers, "Id", "Email", projectSupervisor.UserID); return(View(projectSupervisor)); }
// GET: ProjectSupervisors/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProjectSupervisor projectSupervisor = db.ProjectSupervisors.Find(id); if (projectSupervisor == null) { return(HttpNotFound()); } return(View(projectSupervisor)); }
// GET: ProjectSupervisors/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProjectSupervisor projectSupervisor = db.ProjectSupervisors.Find(id); if (projectSupervisor == null) { return(HttpNotFound()); } ViewBag.StaffNumber = new SelectList(db.AspNetUsers, "Id", "Email", projectSupervisor.UserID); return(View(projectSupervisor)); }
public ActionResult ChooseSupervisors(string Id) { ViewBag.studentId = Id; var SelectedList = new List <SelectListItem>(); ProjectSupervisor projectSupervisor = new ProjectSupervisor(); List <AspNetUser> data = new List <AspNetUser>(); using (ProgressTrackerEntities dc = new ProgressTrackerEntities()) { var supervisors = from rowS in db.AspNetUsers join rowSupervisor in db.ProjectSupervisors on rowS.Id equals rowSupervisor.UserID where rowS.Id == rowSupervisor.UserID //select new AspNetUser { Id = rowSupervisor.UserID }; select rowS; data = supervisors.ToList(); ViewBag.Students = data; return(View(data)); } }
public async Task <ActionResult> RegisterSupervisor(RegisterSupervisorViewModel model, HttpPostedFileBase Picture) { using (var db = new ProgressTrackerEntities()) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email, Name = model.Name, Surname = model.Surname, Title = model.Title, Picture = null }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); var _context = new ApplicationDbContext(); var roleStore = new RoleStore <Microsoft.AspNet.Identity.EntityFramework.IdentityRole>(_context); var roleManager = new RoleManager <IdentityRole>(roleStore); var userStore = new UserStore <ApplicationUser>(_context); var UseManage = new UserManager <ApplicationUser>(userStore); UseManage.AddToRole(user.Id, "ProjectSupervisor"); var id = user.Id; ProjectSupervisor supervisor = new ProjectSupervisor { UserID = id, }; db.ProjectSupervisors.Add(supervisor); db.SaveChanges(); return(View("DisplayEmail")); //return RedirectToAction("Index", "Home"); } AddErrors(result); } } // If we got this far, something failed, redisplay form return(View(model)); }