public ActionResult EditContact(PersonPrimaryKey personPrimaryKey) { var person = personPrimaryKey.EntityObject; var viewModel = new EditContactViewModel(person); return(ViewAddContact(viewModel, person)); }
/// <summary> /// Impersonate the given User ID. /// Designed to be callable by other methods in other controllers /// </summary> /// <param name="activeController"></param> /// <param name="personIDToImpersonate"></param> /// <param name="optionalPreviousPageUri">Optional URI to the referring page. May be null or blank if not known.</param> public static void ImpersonatePersonID(FirmaBaseController activeController, PersonPrimaryKey personIDToImpersonate, Uri optionalPreviousPageUri) { Person personToImpersonate = personIDToImpersonate.EntityObject; if (activeController.CurrentFirmaSession.Person.PersonID == personToImpersonate.PersonID) { string currentPersonFullName = activeController.CurrentFirmaSession.Person.GetFullNameFirstLast(); string impersonationWarning = $"Attempted to impersonate person {currentPersonFullName}, but you are already acting as {currentPersonFullName}. Nothing done."; activeController.SetErrorForDisplay(impersonationWarning); return; } AssertImpersonationAllowedByEnvironment(); AssertFirmaSessionCanImpersonate(activeController.CurrentFirmaSession); AssertNotAttemptingToImpersonateSelf(activeController.CurrentFirmaSession, personToImpersonate.PersonID); AssertPersonCanBeImpersonated(activeController.CurrentFirmaSession, personToImpersonate); activeController.CurrentFirmaSession.ImpersonateUser(personToImpersonate, optionalPreviousPageUri, out var statusMessage, out var statusWarning); activeController.SetInfoForDisplay(statusMessage); // Warning is optional if (statusWarning != null) { // In Firma, is this the best way to express a "warning" message? Unsure. activeController.SetMessageForDisplay(statusWarning); } HttpRequestStorage.DatabaseEntities.SaveChangesWithNoAuditing(activeController.CurrentPerson.TenantID); }
public PartialViewResult EditStewardshipAreas(PersonPrimaryKey personPrimaryKey) { var person = personPrimaryKey.EntityObject; var viewModel = new EditUserStewardshipAreasViewModel(person, MultiTenantHelpers.GetProjectStewardshipAreaType()); return(ViewEditStewardshipAreas(viewModel)); }
public PartialViewResult EditRoles(PersonPrimaryKey personPrimaryKey) { var person = personPrimaryKey.EntityObject; var viewModel = new EditRolesViewModel(person); return(ViewEdit(viewModel)); }
public ViewResult Detail(PersonPrimaryKey personPrimaryKey) { var person = personPrimaryKey.EntityObject; var userNotificationGridSpec = new UserNotificationGridSpec(); var userNotificationGridDataUrl = SitkaRoute <UserController> .BuildUrlFromExpression(x => x.UserNotificationsGridJsonData(personPrimaryKey)); var basicProjectInfoGridSpec = new Views.Project.ProjectInfoForUserDetailGridSpec(CurrentPerson, person) { ObjectNameSingular = $"{FieldDefinition.Project.GetFieldDefinitionLabel()}", ObjectNamePlural = $"{FieldDefinition.Project.GetFieldDefinitionLabelPluralized()}", SaveFiltersInCookie = true }; const string basicProjectInfoGridName = "userProjectListGrid"; var projectInfoForUserDetailGridDataUrl = SitkaRoute <UserController> .BuildUrlFromExpression(tc => tc.ProjectInfoForUserDetailGridJsonData(person)); var activateInactivateUrl = SitkaRoute <UserController> .BuildUrlFromExpression(x => x.ActivateInactivatePerson(person)); var agreements = GetAgreementsByPerson(person); var viewData = new DetailViewData(CurrentPerson, person, basicProjectInfoGridSpec, basicProjectInfoGridName, projectInfoForUserDetailGridDataUrl, userNotificationGridSpec, "userNotifications", userNotificationGridDataUrl, activateInactivateUrl, agreements.Any(x => x.AgreementFileResourceID.HasValue)); return(RazorView <Detail, DetailViewData>(viewData)); }
public PartialViewResult Delete(PersonPrimaryKey personPrimaryKey) { var person = personPrimaryKey.EntityObject; var viewModel = new ConfirmDialogFormViewModel(person.PersonID); return(ViewDelete(person, viewModel)); }
public PartialViewResult EditJurisdiction(PersonPrimaryKey personPrimaryKey) { var person = personPrimaryKey.EntityObject; var viewModel = new EditUserJurisdictionsViewModel(person, CurrentPerson); return(ViewEditJurisdiction(viewModel)); }
public PartialViewResult ChangePassword(PersonPrimaryKey personPrimaryKey) { LocalAuthenticationController.RequireLocalAuthMode(); var person = personPrimaryKey.EntityObject; var viewModel = new ChangePasswordViewModel(person); return(ViewChangePassword(viewModel, CurrentFirmaSession)); }
public PartialViewResult EditUser(PersonPrimaryKey personPrimaryKey) { LocalAuthenticationController.RequireLocalAuthMode(); var person = personPrimaryKey.EntityObject; var viewModel = new EditUserViewModel(person); return(ViewEditUser(viewModel)); }
public PartialViewResult EditPersonOrganizationPrimaryContacts(PersonPrimaryKey personPrimaryKey) { var person = personPrimaryKey.EntityObject; var organizationIDs = person.OrganizationsWhereYouAreThePrimaryContactPerson.Select(org => org.OrganizationID).ToList(); var viewModel = new EditPersonOrganizationsViewModel(organizationIDs); return(ViewEditPersonOrganizations(viewModel)); }
public ExcelResult UserAgreementsExcelDownload(PersonPrimaryKey personPrimaryKey) { var person = personPrimaryKey.EntityObject; var agreements = GetAgreementsByPerson(person); var workbookTitle = $"{FieldDefinition.Agreement.GetFieldDefinitionLabelPluralized()} for {person.FullNameFirstLast}"; return(AgreementController.AgreementsExcelDownloadImpl(agreements, workbookTitle)); }
public GridJsonNetJObjectResult <Notification> UserNotificationsGridJsonData(PersonPrimaryKey personPrimaryKey) { var person = personPrimaryKey.EntityObject; var gridSpec = new UserNotificationGridSpec(); var notifications = person.Notifications.OrderByDescending(x => x.NotificationDate).ToList(); var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <Notification>(notifications, gridSpec); return(gridJsonNetJObjectResult); }
public GridJsonNetJObjectResult <Project> ProjectsGridJsonData(PersonPrimaryKey personPrimaryKey) { var person = personPrimaryKey.EntityObject; var gridSpec = new Views.Project.UserProjectGridSpec(CurrentFirmaSession, person); var projectPersons = person.GetProjectsWhereYouAreAContact(); var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <Project>(projectPersons, gridSpec); return(gridJsonNetJObjectResult); }
public GridJsonNetJObjectResult <ActionItem> ActionItemsUserGridJsonData(PersonPrimaryKey personPrimaryKey) { var person = personPrimaryKey.EntityObject; var gridSpec = new ActionItemsUserGridSpec(CurrentFirmaSession); var actionItems = person.ActionItemsWhereYouAreTheAssignedToPerson.OrderByDescending(x => x.DueByDate).ToList(); var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <ActionItem>(actionItems, gridSpec); return(gridJsonNetJObjectResult); }
public ActionResult EditRoles(PersonPrimaryKey personPrimaryKey, EditRolesViewModel viewModel) { var person = personPrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewEdit(viewModel)); } viewModel.UpdateModel(person, CurrentPerson); return(new ModalDialogFormJsonResult()); }
public ActionResult Delete(PersonPrimaryKey personPrimaryKey, ConfirmDialogFormViewModel viewModel) { var person = personPrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewDelete(person, viewModel)); } person.DeleteFull(HttpRequestStorage.DatabaseEntities); return(new ModalDialogFormJsonResult()); }
public ActionResult EditPersonOrganizationPrimaryContacts(PersonPrimaryKey personPrimaryKey, EditPersonOrganizationsViewModel viewModel) { if (!ModelState.IsValid) { return(ViewEditPersonOrganizations(viewModel)); } var person = personPrimaryKey.EntityObject; viewModel.UpdateModel(person, HttpRequestStorage.DatabaseEntities.Organizations.ToList()); return(new ModalDialogFormJsonResult()); }
public ActionResult EditRoles(PersonPrimaryKey personPrimaryKey, EditRolesViewModel viewModel) { var person = personPrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewEdit(viewModel)); } viewModel.UpdateModel(person, CurrentPerson); SetMessageForDisplay($"Successfully updated the roles for {person.GetFullNameFirstLastAsUrl()}"); return(new ModalDialogFormJsonResult()); }
public GridJsonNetJObjectResult <Agreement> UserAgreementsGridJsonData(PersonPrimaryKey personPrimaryKey) { var person = personPrimaryKey.EntityObject; var agreements = GetAgreementsByPerson(person); var gridSpec = new AgreementGridSpec(CurrentPerson, agreements.Any(x => x.AgreementFileResourceID.HasValue), false, false) { CustomExcelDownloadUrl = SitkaRoute <UserController> .BuildUrlFromExpression(tc => tc.UserAgreementsExcelDownload(personPrimaryKey)) }; var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <Agreement>(agreements, gridSpec); return(gridJsonNetJObjectResult); }
public ActionResult EditUser(PersonPrimaryKey personPrimaryKey, EditUserViewModel viewModel) { LocalAuthenticationController.RequireLocalAuthMode(); var personBeingEdited = personPrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewEditUser(viewModel)); } viewModel.UpdateModel(personBeingEdited, CurrentFirmaSession); return(new ModalDialogFormJsonResult()); }
public ActionResult EditJurisdiction(PersonPrimaryKey personPrimaryKey, EditUserJurisdictionsViewModel viewModel) { var person = personPrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewEditJurisdiction(viewModel)); } HttpRequestStorage.DatabaseEntities.StormwaterJurisdictionPeople.Load(); viewModel.UpdateModel(person, HttpRequestStorage.DatabaseEntities.StormwaterJurisdictionPeople.Local); SetMessageForDisplay($"Assigned {FieldDefinitionType.Jurisdiction.GetFieldDefinitionLabelPluralized()} successfully changed for {person.GetFullNameFirstLastAndOrgAsUrl()}."); return(new ModalDialogFormJsonResult()); }
public PartialViewResult GetWebServiceAccessToken(PersonPrimaryKey personPrimaryKey) { Check.Require(personPrimaryKey.PrimaryKeyValue == CurrentPerson.PersonID, "The person ID passed in to GetWebServiceAccessToken must match the logged in user!"); var person = personPrimaryKey.EntityObject; if (!person.WebServiceAccessToken.HasValue) { person.WebServiceAccessToken = Guid.NewGuid(); HttpRequestStorage.DatabaseEntities.SaveChanges(CurrentPerson); } var viewData = new ViewAccessTokenViewData(person.WebServiceAccessToken.Value, SitkaRoute <WebServicesController> .BuildUrlFromExpression(c => c.List())); return(RazorPartialView <ViewAccessToken, ViewAccessTokenViewData>(viewData)); }
public ActionResult EditContact(PersonPrimaryKey personPrimaryKey, EditContactViewModel viewModel) { var person = personPrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewAddContact(viewModel, person)); } viewModel.UpdateModel(person); SetMessageForDisplay($"Successfully updated {person.GetFullNameFirstLastAsUrl()}"); return(new ModalDialogFormJsonResult()); }
public ActionResult ImpersonateUser(PersonPrimaryKey personToImpersonate) { AssertImpersonationAllowedByEnvironment(); AssertFirmaSessionCanImpersonate(this.CurrentFirmaSession); Uri previousPageUri = Request.UrlReferrer; ImpersonatePersonID(this, personToImpersonate, previousPageUri); // Drop them on the home page for any new impersonation. // // This is because we don't know what a given user might have access to, so we can't be sure the current page // will be accessible any more. return(RedirectToAction(new SitkaRoute <HomeController>(c => c.Index()))); }
public ActionResult SinglePageImpersonateUser(PersonPrimaryKey personToImpersonate) { return(ImpersonateUser(personToImpersonate)); /* * AssertImpersonationAllowedByEnvironment(); * AssertFirmaSessionCanImpersonate(this.CurrentFirmaSession); * * var personToImpersonate = People.GetPerson(personIDToImpersonate, true); * * var viewData = new SinglePageImpersonateUserViewData(TaurusSession, personToImpersonate); * var viewModel = new SinglePageImpersonateUserViewModel(); * return View<SinglePageImpersonateUser, SinglePageImpersonateUserViewData, SinglePageImpersonateUserViewModel>(viewData, viewModel); */ //throw new NotImplementedException(); }
public ViewResult Detail(PersonPrimaryKey personPrimaryKey) { var person = personPrimaryKey.EntityObject; var userNotificationGridSpec = new UserNotificationGridSpec(); var userNotificationGridDataUrl = SitkaRoute <UserController> .BuildUrlFromExpression(x => x.UserNotificationsGridJsonData(personPrimaryKey)); var activateInactivateUrl = SitkaRoute <UserController> .BuildUrlFromExpression(x => x.ActivateInactivatePerson(person)); var viewData = new DetailViewData(CurrentPerson, person, userNotificationGridSpec, "userNotifications", userNotificationGridDataUrl, activateInactivateUrl); return(RazorView <Detail, DetailViewData>(viewData)); }
public ViewResult Detail(PersonPrimaryKey personPrimaryKey) { ShowWarningAboutInactivatedUserForOrganizationPrimaryContact(personPrimaryKey.EntityObject); var person = personPrimaryKey.EntityObject; var userNotificationGridSpec = new UserNotificationGridSpec(); var userNotificationGridDataUrl = SitkaRoute <UserController> .BuildUrlFromExpression( x => x.UserNotificationsGridJsonData(personPrimaryKey)); var basicProjectInfoGridSpec = new Views.Project.UserProjectGridSpec(CurrentFirmaSession, person) { ObjectNameSingular = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} where {person.GetFullNameFirstLast()} is a Contact", ObjectNamePlural = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()} where {person.GetFullNameFirstLast()} is a Contact", SaveFiltersInCookie = true }; const string basicProjectInfoGridName = "userProjectListGrid"; var basicProjectInfoGridDataUrl = SitkaRoute <UserController> .BuildUrlFromExpression(tc => tc.ProjectsGridJsonData(person)); var activateInactivateUrl = SitkaRoute <UserController> .BuildUrlFromExpression(x => x.ActivateInactivatePerson(person)); var actionItemsGridSpec = new ActionItemsUserGridSpec(CurrentFirmaSession); var actionItemsGridName = "actionItems"; var actionItemsGridDataUrl = SitkaRoute <ActionItemController> .BuildUrlFromExpression(c => c.ActionItemsUserGridJsonData(person)); var viewData = new DetailViewData(this.CurrentFirmaSession, person, basicProjectInfoGridSpec, basicProjectInfoGridName, basicProjectInfoGridDataUrl, userNotificationGridSpec, "userNotifications", userNotificationGridDataUrl, activateInactivateUrl, actionItemsGridSpec, actionItemsGridName, actionItemsGridDataUrl); return(RazorView <Detail, DetailViewData>(viewData)); }
public ActionResult EditStewardshipAreas(PersonPrimaryKey personPrimaryKey, EditUserStewardshipAreasViewModel viewModel) { var person = personPrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewEditStewardshipAreas(viewModel)); } var projectStewardshipAreaType = MultiTenantHelpers.GetProjectStewardshipAreaType().ToEnum; switch (projectStewardshipAreaType) { case ProjectStewardshipAreaTypeEnum.ProjectStewardingOrganizations: HttpRequestStorage.DatabaseEntities.Organizations.Load(); viewModel.UpdateModel(person, HttpRequestStorage.DatabaseEntities.AllPersonStewardOrganizations.Local); break; case ProjectStewardshipAreaTypeEnum.TaxonomyBranches: HttpRequestStorage.DatabaseEntities.TaxonomyBranches.Load(); viewModel.UpdateModel(person, HttpRequestStorage.DatabaseEntities.AllPersonStewardTaxonomyBranches.Local); break; case ProjectStewardshipAreaTypeEnum.GeospatialAreas: HttpRequestStorage.DatabaseEntities.GeospatialAreas.Load(); viewModel.UpdateModel(person, HttpRequestStorage.DatabaseEntities.AllPersonStewardGeospatialAreas.Local); break; default: throw new InvalidOperationException( "The Stewardship Area editor should only be allowed for tenants with a Project Stewardship Area Type"); } SetMessageForDisplay( $"Assigned {FieldDefinitionEnum.ProjectStewardshipArea.ToType().GetFieldDefinitionLabelPluralized()} successfully changed for {person.GetFullNameFirstLast()}."); return(new ModalDialogFormJsonResult()); }
public ActionResult ChangePassword(PersonPrimaryKey personPrimaryKey, ChangePasswordViewModel viewModel) { LocalAuthenticationController.RequireLocalAuthMode(); var personBeingEdited = personPrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewChangePassword(viewModel, CurrentFirmaSession)); } var personAccount = personBeingEdited.PersonLoginAccount; var saltAndHash = PBKDF2PasswordHash.CreateHash(viewModel.NewPassword); personAccount.PasswordSalt = saltAndHash.PasswordSalt; personAccount.PasswordHash = saltAndHash.PasswordHashed; HttpRequestStorage.DatabaseEntities.SaveChanges(); SetMessageForDisplay($"{personBeingEdited.GetFullNameFirstLast()}'s password had been updated."); return(new ModalDialogFormJsonResult()); }
public ActionResult ActivateInactivatePerson(PersonPrimaryKey personPrimaryKey, ConfirmDialogFormViewModel viewModel) { var person = personPrimaryKey.EntityObject; if (person.IsActive) { Check.Require(!person.OrganizationsWhereYouAreThePrimaryContactPerson.Any(), $@"You cannot inactive user '{person.FullNameFirstLast}' because { person.FirstName } is the {FieldDefinition.OrganizationPrimaryContact.GetFieldDefinitionLabel()} for one or more {FieldDefinition.Organization.GetFieldDefinitionLabelPluralized()}!"); } if (!ModelState.IsValid) { return(ViewActivateInactivatePerson(person, viewModel)); } if (person.IsActive) { // if the person is currently active, we need to remove them from the support email list no matter what since we are about to inactivate the person person.ReceiveSupportEmails = false; } person.IsActive = !person.IsActive; return(new ModalDialogFormJsonResult()); }