public static UserSetting UserSettingFromVMEditAccountSettings(VMEditAccountSettings n) { UserSetting set = new UserSetting() { IsPublic = n.ProfileVisibility, IsEmailedForViewReport = n.EmailDailyViewReport, IsEmailedForAdminMessage = n.EmailAdminMessage, IsEmailedForCollaborationAddition = n.EmailCollaborationAddition, IsEmailedForCollaborationRequest = n.EmailCollaborationRequest, IsEmailedForCollaborationRemoval = n.EmailCollaborationRemoval, UserId = n.UserID, Id = n.ID }; return set; }
public ActionResult EditAccountSettings() { int idCheck = db.retrieveUserByEmail(User.Identity.Name).Id; bool boolCheck = db.retrieveUserSettings(db.retrieveUserByEmail(User.Identity.Name).Id).IsEmailedForAdminMessage; VMEditAccountSettings model = new VMEditAccountSettings() { EmailAdminMessage = db.retrieveUserSettings(db.retrieveUserByEmail(User.Identity.Name).Id).IsEmailedForAdminMessage, EmailCollaborationAddition = db.retrieveUserSettings(db.retrieveUserByEmail(User.Identity.Name).Id).IsEmailedForCollaborationAddition, EmailCollaborationRemoval = db.retrieveUserSettings(db.retrieveUserByEmail(User.Identity.Name).Id).IsEmailedForCollaborationRemoval, EmailCollaborationRequest = db.retrieveUserSettings(db.retrieveUserByEmail(User.Identity.Name).Id).IsEmailedForCollaborationRequest, EmailDailyViewReport = db.retrieveUserSettings(db.retrieveUserByEmail(User.Identity.Name).Id).IsEmailedForViewReport, ProfileVisibility = db.retrieveUserSettings(db.retrieveUserByEmail(User.Identity.Name).Id).IsPublic, UserID = db.retrieveUserSettings(db.retrieveUserByEmail(User.Identity.Name).Id).UserId, ID = db.retrieveUserSettings(db.retrieveUserByEmail(User.Identity.Name).Id).Id }; return View(model); }
public ActionResult EditAccountSettings(VMEditAccountSettings model) { if (ModelState.IsValid) { UserSetting test = Translator.UserSettingFromVMEditAccountSettings(model); db.updateUserSettings(test, model.UserID); string completedUpdate = "You have updated your settings"; VMGeneralMessage message = new VMGeneralMessage("AccountUpdated","Updated Account", new string[] {completedUpdate}); return View("GeneralMessage", message); } return View(model); }
public ActionResult AccountCreation(VMCreatingUser model) { bool isValidInput = true; List<ContactInfo> contacts = new List<ContactInfo>(); if (!AllContactInfosVerified(out contacts)) { isValidInput = false; } List<Education> educations = new List<Education>(); if (!AllEducationsVerified(out educations)) { isValidInput = false; } List<Link> links = new List<Link>(); if (!AllLinksVerified(out links)) { isValidInput = false; } if (ModelState.IsValid) { if (!model.Email.Equals(model.ConfirmationEmail)) { isValidInput = false; ModelState.AddModelError("ConfirmationEmail", "Email and Confirmation Email do not match."); } if (model.Password.Count() < 6) { isValidInput = false; ModelState.AddModelError("Password", "Your Password must be at least six characters long."); } else if (!model.Password.Equals(model.ConfirmationPassword)) { isValidInput = false; ModelState.AddModelError("ConfirmationPassword", "Password and Confirmation Password do not match."); } } if (isValidInput && ModelState.IsValid) { try { string confirmationToken = WebSecurity.CreateUserAndAccount(model.Email, model.Password, new { model.FirstName, model.LastName },true); VMEditAccountSettings settings = new VMEditAccountSettings() { EmailAdminMessage = false, EmailCollaborationAddition = false, EmailCollaborationRemoval = false, EmailCollaborationRequest = false, EmailDailyViewReport = false, ProfileVisibility = false, UserID = db.retrieveUserByEmail(model.Email).Id }; db.addUserSettings(Translator.UserSettingFromVMEditAccountSettings(settings)); dynamic email = new Email("RegEmail"); email.To = model.Email; email.UserName = model.FirstName; email.ConfirmationToken = confirmationToken; try { email.Send(); } catch (Exception e) { } int NewUserId = db.retrieveUserByEmail(model.Email).Id; foreach (ContactInfo c in contacts) { db.addContactInfo(c, NewUserId); } foreach (Education e in educations) { db.addEducation(e, NewUserId); } foreach (Link l in links) { db.addLink(l, NewUserId); } System.Web.Security.Roles.AddUserToRole(model.Email, "User"); return RedirectToAction("RegistratoinStepTwo", "User"); } catch (MembershipCreateUserException e) { ModelState.AddModelError("", ErrorCodeToString(e.StatusCode)); } } User u = new User(); u.FirstName = model.FirstName; u.LastName = model.LastName; u.Email = model.Email; u.ContactInfoes = contacts; u.Links = links; u.Educations = educations; return View(new VMCreatingUser(u)); }