public static string GetFundingSourceCustomAttributesValue(this FundingSource fundingSource , FundingSourceCustomAttributeType fundingSourceCustomAttributeType , Dictionary <int, List <FundingSourceCustomAttribute> > fundingSourceCustomAttributeDictionary , Dictionary <int, List <FundingSourceCustomAttributeValue> > fundingSourceCustomAttributeValueDictionary) { var fundingSourceCustomAttributesList = fundingSourceCustomAttributeDictionary.ContainsKey(fundingSource.FundingSourceID) ? fundingSourceCustomAttributeDictionary[fundingSource.FundingSourceID] : new List <FundingSourceCustomAttribute>(); var fundingSourceCustomAttribute = fundingSourceCustomAttributesList.SingleOrDefault(x => x.FundingSourceCustomAttributeTypeID == fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeID); if (fundingSourceCustomAttribute != null) { var fundingSourceCustomAttributeValues = fundingSourceCustomAttributeValueDictionary.ContainsKey(fundingSourceCustomAttribute .FundingSourceCustomAttributeID) ? fundingSourceCustomAttributeValueDictionary[ fundingSourceCustomAttribute.FundingSourceCustomAttributeID] : new List <FundingSourceCustomAttributeValue>(); if (fundingSourceCustomAttributeType.FundingSourceCustomAttributeDataType == FundingSourceCustomAttributeDataType.DateTime) { return(DateTime.TryParse(fundingSourceCustomAttributeValues.Single().AttributeValue, out var date) ? date.ToShortDateString() : null); } else { return(string.Join(", ", fundingSourceCustomAttributeValues.Select(x => x.AttributeValue))); } } else { return("None"); } }
public static bool HasViewPermission(this FundingSourceCustomAttributeType fundingSourceCustomAttributeType, FirmaSession currentFirmaSession) { return(fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeRoles .Where(x => x.FundingSourceCustomAttributeTypeRolePermissionType == FundingSourceCustomAttributeTypeRolePermissionType.View).Select(x => x.Role) .Contains(currentFirmaSession.Role) || new FirmaAdminFeature().HasPermissionByFirmaSession(currentFirmaSession)); }
public static HtmlString GetViewableRoles(this FundingSourceCustomAttributeType fundingSourceCustomAttributeType) { var customAttributeTypViewableRoles = HttpRequestStorage.DatabaseEntities.FundingSourceCustomAttributeTypeRoles.Where(x => x.FundingSourceCustomAttributeTypeID == fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeID).ToList(); return(new HtmlString(customAttributeTypViewableRoles.Any() ? String.Join(", ", customAttributeTypViewableRoles.OrderBy(x => x.Role?.SortOrder).Where(x => x.FundingSourceCustomAttributeTypeRolePermissionType == FundingSourceCustomAttributeTypeRolePermissionType.View).Select(x => x.Role.GetRoleDisplayName()).ToList()) : ViewUtilities.NoAnswerProvided)); }
private PartialViewResult ViewEdit(EditViewModel viewModel, FundingSourceCustomAttributeType fundingSourceCustomAttributeType) { var instructionsFirmaPage = FirmaPageTypeEnum.ManageFundingSourceCustomAttributeTypeInstructions.GetFirmaPage(); var submitUrl = ModelObjectHelpers.IsRealPrimaryKeyValue(viewModel.FundingSourceCustomAttributeTypeID) ? SitkaRoute <FundingSourceCustomAttributeTypeController> .BuildUrlFromExpression(x => x.Edit(viewModel.FundingSourceCustomAttributeTypeID)) : SitkaRoute <FundingSourceCustomAttributeTypeController> .BuildUrlFromExpression(x => x.New()); var viewData = new EditViewData(CurrentFirmaSession, MeasurementUnitType.All, FundingSourceCustomAttributeDataType.All, Role.All, submitUrl, instructionsFirmaPage, fundingSourceCustomAttributeType); return(RazorPartialView <Edit, EditViewData, EditViewModel>(viewData, viewModel)); }
public ActionResult New(EditViewModel viewModel) { if (!ModelState.IsValid) { return(ViewEdit(viewModel, null)); } var fundingSourceCustomAttributeType = new FundingSourceCustomAttributeType(String.Empty, FundingSourceCustomAttributeDataType.String, false, false); viewModel.UpdateModel(fundingSourceCustomAttributeType, CurrentFirmaSession); HttpRequestStorage.DatabaseEntities.AllFundingSourceCustomAttributeTypes.Add(fundingSourceCustomAttributeType); HttpRequestStorage.DatabaseEntities.SaveChanges(); SetMessageForDisplay($"{FieldDefinitionEnum.FundingSourceCustomAttribute.ToType().GetFieldDefinitionLabel()} {fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeName} successfully created."); return(new ModalDialogFormJsonResult()); }
public static string GetFundingSourceCustomAttributesValue(this ProjectFundingSourceExpenditure projectFundingSourceExpenditure, FundingSourceCustomAttributeType fundingSourceCustomAttributeType) { var fundingSourceCustomAttribute = projectFundingSourceExpenditure.FundingSource.FundingSourceCustomAttributes.SingleOrDefault(x => x.FundingSourceCustomAttributeTypeID == fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeID); if (fundingSourceCustomAttribute != null) { if (fundingSourceCustomAttributeType.FundingSourceCustomAttributeDataType == FundingSourceCustomAttributeDataType.DateTime) { return(DateTime.TryParse(fundingSourceCustomAttribute.GetCustomAttributeValues().Single().AttributeValue, out var date) ? date.ToShortDateString() : null); } else { return(string.Join(", ", fundingSourceCustomAttribute.FundingSourceCustomAttributeValues.Select(x => x.AttributeValue))); } } else { return("None"); } }
private PartialViewResult ViewDeleteFundingSourceCustomAttributeType(FundingSourceCustomAttributeType fundingSourceCustomAttributeType, ConfirmDialogFormViewModel viewModel) { var viewData = new ConfirmDialogFormViewData($"Are you sure you want to delete {FieldDefinitionEnum.FundingSourceCustomAttribute.ToType().GetFieldDefinitionLabel()} \"{fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeName}\"?", true); return(RazorPartialView <ConfirmDialogForm, ConfirmDialogFormViewData, ConfirmDialogFormViewModel>(viewData, viewModel)); }
public static string GetDescriptionUrl(this FundingSourceCustomAttributeType fundingSourceCustomAttributeType) => DescriptionUrlTemplate.ParameterReplace(fundingSourceCustomAttributeType.FundingSourceCustomAttributeTypeID);