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; } }
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 })); }
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); } }
public ActionResult Create(StaffViewModel objViewModel) { string token = this.CreateToken(objViewModel, _userStatistics.UserId, _userStatistics.OrganizationId); if (!(string.IsNullOrEmpty(token))) { long userId = WebSecurity.RegisterNewUser(objViewModel.Email, "none", objViewModel.Email, false, objViewModel.Profile.FirstName, objViewModel.Profile.LastName, objViewModel.OrganizationId, token); DBConnectionString.Profile Profile = new DBConnectionString.Profile(); if (userId != -1) { Profile.UserId = userId; Profile.Title = objViewModel.Profile.Title; Profile.Address1 = "none"; Profile.Address2 = "none"; Profile.InsertedOn = DateTime.Now; Profile.EmailAddress1 = objViewModel.Email; Profile.HomeTelephoneNumber = objViewModel.Profile.HomeTelephoneNumber; Profile.SecurityQuestionId = 1; Profile.SecurityAnswer = "none"; Profile.DateOfBirth = objViewModel.DateOfBirth; Profile.ModifiedOn = null; Profile.MobileNumber = objViewModel.Profile.MobileNumber; int recAffected = Convert.ToInt32(Profile.Insert()); long id = Profile.ProfileId; string roleName = UserRoles.Student.ToString(); //((UserRoles)Convert.ToInt16(Token.RoleId)).ToString(); Roles.AddUserToRole(objViewModel.Email, roleName); //objViewModel.UserId = userId; objViewModel.InsertedBy = _userStatistics.UserId; objViewModel.OrganizationId = _userStatistics.OrganizationId; objViewModel.UserId = userId; objViewModel.StaffId = this.repository.CreateNewStaff(objViewModel); this.repository.AssignSubjectToTeacher(objViewModel); this.repository.SetStaffPermissions(objViewModel);//Assign Staff Permissions SaveFiles(token, this.GetType().Name, objViewModel.StaffId); EmailHandler.Utilities.SendRegistationEmail(token, objViewModel.Email); return(RedirectToAction("Index")); } } StaffViewModel objVM = this.LoadViewModel(); return(View(objVM)); }
public ActionResult Create(StaffViewModel objViewModel) { string token = this.CreateToken(objViewModel, _userStatistics.UserId, _userStatistics.OrganizationId); if (!(string.IsNullOrEmpty(token))) { long userId = WebSecurity.RegisterNewUser(objViewModel.Email, "none", objViewModel.Email, false, objViewModel.Profile.FirstName, objViewModel.Profile.LastName, objViewModel.OrganizationId, token); DBConnectionString.Profile Profile = new DBConnectionString.Profile(); if (userId != -1) { Profile.UserId = userId; Profile.Title = objViewModel.Profile.Title; Profile.Address1 = "none"; Profile.Address2 = "none"; Profile.InsertedOn = DateTime.Now; Profile.EmailAddress1 = objViewModel.Email; Profile.HomeTelephoneNumber = objViewModel.Profile.HomeTelephoneNumber; Profile.SecurityQuestionId = 1; Profile.SecurityAnswer = "none"; Profile.DateOfBirth = objViewModel.DateOfBirth; Profile.ModifiedOn = null; Profile.MobileNumber = objViewModel.Profile.MobileNumber; int recAffected = Convert.ToInt32(Profile.Insert()); long id = Profile.ProfileId; string roleName = UserRoles.Student.ToString(); //((UserRoles)Convert.ToInt16(Token.RoleId)).ToString(); Roles.AddUserToRole(objViewModel.Email, roleName); //objViewModel.UserId = userId; objViewModel.InsertedBy = _userStatistics.UserId; objViewModel.OrganizationId = _userStatistics.OrganizationId; objViewModel.UserId = userId; objViewModel.StaffId = this.repository.CreateNewStaff(objViewModel); this.repository.AssignSubjectToTeacher(objViewModel); this.repository.SetStaffPermissions(objViewModel);//Assign Staff Permissions SaveFiles(token, this.GetType().Name, objViewModel.StaffId); EmailHandler.Utilities.SendRegistationEmail(token, objViewModel.Email); return RedirectToAction("Index"); } } StaffViewModel objVM = this.LoadViewModel(); return View(objVM); }
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 }); }
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; } }