Ejemplo n.º 1
0
        public ActionResult RegisterUserStep3(string token)
        {
            Profile objProfile = new Profile();
            RegistrationToken objToken = repository.GetRegistrationCode(token);
            StudentContext context = new StudentContext();
            Student student = context.Students.Find(objToken.StudentId);
            if (student != null)
            {
                objProfile.FirstName = student.FullName;
                objProfile.EmailAddress1 = student.Email;
            }

            objProfile.RegistrationToken = token;
            objProfile.TitleList = new SelectList(new[] { new { Id = "Mr.", Value = "Mr." }, new { Id = "Miss.", Value = "Miss." } }, "Id", "Value");
            return View(objProfile);
        }
Ejemplo n.º 2
0
 public ActionResult RegisterUserStep5(long userId)
 {
     Profile objProfile = new Profile();
     objProfile.UserId = userId;
     objProfile.SecurityQuestionList = new SelectList(repository.SecurityQuestions(), "Id", "Question");
     return View(objProfile);
 }
Ejemplo n.º 3
0
        public ActionResult RegisterUserStep5(Profile objProfile)
        {
            DBConnectionString.User User = DBConnectionString.User.FirstOrDefault("select * from Users where UserId=@0", objProfile.UserId);
            DBConnectionString.Profile Profile = DBConnectionString.Profile.FirstOrDefault("select * from Profile where UserId=@0", objProfile.UserId);
            // User.Password = objUser.Password;
            WebSecurity.ResetPassword(User.Username, objProfile.Password);
            User = DBConnectionString.User.FirstOrDefault("select * from Users where UserId=@0", objProfile.UserId);

            Profile.SecurityQuestionId = objProfile.SecurityQuestionId;
            Profile.SecurityAnswer = objProfile.SecurityAnswer;
            if (User.Update() > 0 && Profile.Update() > 0)
            {
                return RedirectToAction("RegisterUserStep6", new { userId = User.UserId });
            }
            return View(objProfile);
        }
Ejemplo n.º 4
0
        public ActionResult RegisterUserStep4(Profile objProfile)
        {
            DBConnectionString.User User = DBConnectionString.User.FirstOrDefault("select * from Users where UserId=@0", objProfile.UserId);
            DBConnectionString.Profile Profile = DBConnectionString.Profile.FirstOrDefault("select * from Profile where UserId=@0", objProfile.UserId);
            User.Email = objProfile.EmailAddress1;
            Profile.MobileNumber = objProfile.MobileNumber;
            Profile.HomeTelephoneNumber = objProfile.HomeTelephoneNumber;
            Profile.EmailAddress1 = objProfile.EmailAddress1;
            Profile.HomeTelephoneNumber = objProfile.HomeTelephoneNumber;

            if (User.Update() > 0 && Profile.Update() > 0)
            {
                return RedirectToAction("RegisterUserStep5", new { userId = User.UserId });
            }
            return View(objProfile);
        }
Ejemplo n.º 5
0
 public ActionResult RegisterUserStep4(long userId)
 {
     Profile objProfile = new Profile();
     objProfile.UserId = userId;
     return View(objProfile);
 }
Ejemplo n.º 6
0
        public ActionResult RegisterUserStep3(Profile objProfile)
        {
            RegistrationToken Token = repository.GetRegistrationCode(objProfile.RegistrationToken);
            // RegistrationToken objToken = repository.GetRegistrationCode(objProfile.RegistrationToken);
            StudentContext context = new StudentContext();
            Student student = new Student();
            Staff staff = new Staff();
            if (Token.StaffId != null)
            {
                staff = context.Staff.Find(Token.StaffId);
            }

            if (Token.StudentId != null)
            {
                student = context.Students.Find(Token.StudentId);
            }
            //objProfile.RegistrationToken=Toke
            long userId = WebSecurity.RegisterNewUser(objProfile.UserName, "none", "none", false, objProfile.FirstName, objProfile.LastName, Token.OrganizationId, Token.Token);
            if (student != null)
            {
                student.UserId = userId;

            }

            if (staff != null)
            {
                staff.UserId = userId;
            }

            context.SaveChanges();
            DBConnectionString.Profile Profile = new DBConnectionString.Profile();
            if (userId != -1)
            {
                Profile.UserId = userId;
                Profile.Title = objProfile.Title;
                Profile.Address1 = "none";
                Profile.Address2 = "none";
                Profile.InsertedOn = DateTime.Now;
                Profile.EmailAddress1 = "*****@*****.**";
                Profile.HomeTelephoneNumber = DateTime.Now.Ticks.ToString();
                Profile.SecurityQuestionId = 1;
                Profile.SecurityAnswer = "none";
                Profile.DateOfBirth = objProfile.DateOfBirth;
                Profile.ModifiedOn = null;
                Profile.MobileNumber = "none";

                int recAffected = Convert.ToInt32(Profile.Insert());

                string roleName = ((UserRoles)Convert.ToInt16(Token.RoleId)).ToString();
                Roles.AddUserToRole(objProfile.UserName, roleName);

                return RedirectToAction("RegisterUserStep4", new { userId });
            }
            return View("RegisterUserStep3", new { token = Token.Token });
        }
Ejemplo n.º 7
0
        public bool UpdateUserProfile(Profile objModel)
        {
            PetaPoco.Database db = new PetaPoco.Database("DBConnectionString");
            DBConnectionString.User user = DBConnectionString.User.SingleOrDefault(objModel.UserId);
            DBConnectionString.Profile profile = db.Query<DBConnectionString.Profile>("Select * from  profile where UserId = @0", objModel.UserId).SingleOrDefault();
            try
            {
                if (user != null)
                {
                    user.FirstName = objModel.FirstName;
                    user.LastName = objModel.LastName;
                    user.Update();
                }

                if (profile != null)
                {
                    profile.Title = objModel.Title;
                    profile.DateOfBirth = objModel.DateOfBirth;
                    profile.MobileNumber = objModel.MobileNumber;
                    profile.HomeTelephoneNumber = objModel.HomeTelephoneNumber;
                    profile.EmailAddress1 = objModel.EmailAddress1;
                    profile.EmailAddress2 = objModel.EmailAddress2;
                    profile.Phone1 = objModel.Phone1;
                    profile.Phone2 = objModel.Phone2;
                    profile.Address1 = objModel.Address1;
                    profile.Address2 = objModel.Address2;
                    profile.ModifiedOn = objModel.ModifiedOn;
                    profile.Update();
                }
                else
                {
                    profile = new DBConnectionString.Profile();
                    profile.UserId = objModel.UserId;
                    profile.Title = objModel.Title;
                    profile.DateOfBirth = objModel.DateOfBirth;
                    profile.MobileNumber = objModel.MobileNumber;
                    profile.HomeTelephoneNumber = objModel.HomeTelephoneNumber;
                    profile.EmailAddress1 = objModel.EmailAddress1;
                    profile.EmailAddress2 = objModel.EmailAddress2;
                    profile.Phone1 = objModel.Phone1;
                    profile.Phone2 = objModel.Phone2;
                    profile.Address1 = objModel.Address1;
                    profile.Address2 = objModel.Address2;
                    profile.InsertedOn = DateTime.Now;
                    profile.SecurityAnswer = "None";
                    profile.Insert();
                }

                return true;
            }
            catch
            {
                return false;
            }
        }
Ejemplo n.º 8
0
 public bool UpdateProfileImage(Profile objModel)
 {
     PetaPoco.Database db = new PetaPoco.Database("DBConnectionString");
     DBConnectionString.User user = DBConnectionString.User.SingleOrDefault(objModel.UserId);
     DBConnectionString.Profile profile = db.Query<DBConnectionString.Profile>("Select * from  profile where UserId = @0", objModel.UserId).SingleOrDefault();
     try
     {
         if (profile != null)
         {
             profile.ProfileImageUrl = objModel.ProfileImageUrl;
             profile.Update();
         }
         else
         {
             profile.UserId = objModel.UserId;
             profile.ProfileImageUrl = objModel.ProfileImageUrl;
             profile.Insert();
         }
         return true;
     }
     catch (Exception)
     {
         throw;
     }
 }