コード例 #1
0
        //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"));
            }
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(string id)
        {
            ProjectSupervisor projectSupervisor = db.ProjectSupervisors.Find(id);

            db.ProjectSupervisors.Remove(projectSupervisor);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
 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));
 }
コード例 #4
0
        // 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));
        }
コード例 #5
0
        // 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));
        }
コード例 #6
0
        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));
            }
        }
コード例 #7
0
        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));
        }