Ejemplo n.º 1
0
 public ActionResult RegisterAsFaculty(FacultyRegistrationModel FacultyRegistration)
 {
     if (Session["UserId"] != null)
     {
         if (ModelState.IsValid)
         {
             int             UserId  = Convert.ToInt32(Session["UserId"].ToString());
             FacultyWorkInfo details = new FacultyWorkInfo();
             TryUpdateModel(details);
             details.FacultyUserId = Convert.ToInt64(Session["UserId"]);
             details.Status        = true;
             FacultyWorkInfoService.Create(details);
             View_UserDetails Userdetails = UserDetailsViewService.GetUserByUserId(Convert.ToInt32(UserId));
             UserManager.RemoveFromRole(Userdetails.AspnetUsersId, Userdetails.Role);
             UserManager.AddToRole(Userdetails.AspnetUsersId, "Alumni and Faculty");
             TempData["Success"] = UtilitiesClass.SuccessMessage;
             return(RedirectToAction("Profile", "Profile", new { area = "Alumini" }));
         }
         List <GraduationYear> _GraduationYears = new List <GraduationYear>();
         for (int i = 1970; i <= 2015; i++)
         {
             _GraduationYears.Add(new GraduationYear {
                 Year = "" + i, GraduationYearId = i
             });
         }
         FacultyRegistrationModel Faculty = new FacultyRegistrationModel()
         {
             GraduationYears = _GraduationYears,
         };
         return(View(Faculty));
     }
     return(RedirectToAction("Login", "Account", new { area = "" }));
 }
Ejemplo n.º 2
0
        public ActionResult FacultyRegistration(FacultyRegistrationModel FacultyRegistration)
        {
            string userid = "";

            if (null != Session["AspnetUserId"])
            {
                userid = Session["AspnetUserId"].ToString();
            }
            if (ModelState.IsValid)
            {
                FacultyWorkInfo details = new FacultyWorkInfo();
                TryUpdateModel(details);
                details.FacultyUserId = Convert.ToInt64(Session["UserId"]);
                details.Status        = true;
                ApplicationUser applicationUser = new ApplicationUser();
                applicationUser      = UserManager.FindById(userid);
                details.Email        = applicationUser.UserName;
                details.MobileNumber = applicationUser.PhoneNumber;
                FacultyWorkInfoService.Create(details);
                UserDetail userDetails = new UserDetail()
                {
                    Id = Convert.ToInt64(details.FacultyUserId),
                    ProfileInfoPercentage = (int)CustomStatus.ProfileInfoPercentage.EducationDetails,
                };
                UserService.UpdateUser(userDetails);
                UserManager.AddToRole(userid, "Faculty");
                return(JavaScript("window.location = '../Account/Contactinformation'"));
            }
            else
            {
                List <GraduationYear> _GraduationYears = new List <GraduationYear>();
                for (int i = 1970; i <= 2015; i++)
                {
                    _GraduationYears.Add(new GraduationYear {
                        Year = "" + i, GraduationYearId = i
                    });
                }
                FacultyRegistrationModel Faculty = new FacultyRegistrationModel()
                {
                    GraduationYears = _GraduationYears,
                };
                return(PartialView("FacultyRegistrationForm", Faculty));
            }
        }