public static string FormatAmount(object value, bool removeDecimals, LanguageCode cultureName) { var val = Convert.ToString(value); if (string.IsNullOrEmpty(val)) { return(""); } decimal.TryParse(val, out var amount); var culture = CultureInfo.CreateSpecificCulture(cultureName.GetLanguageCodeString()); var format = string.Format(culture, "{0:N2}", amount); if (removeDecimals) { format = string.Format(culture, "{0:n0}", amount); } return(format); }
public EmailType GetTemplateType(string resource, LanguageCode culture, int?myChannel = null) { if (myChannel != null) { _channelId = (int)myChannel; } switch (resource) { #region Confirm case "Confirm": switch (_channelId) { case 1: switch (culture.GetLanguageCodeString()) { case @"en-US": // This is how whole method was... return(EmailType.ChannelOneConfirmEn); default: return(EmailType.ChannelOneConfirmDa); } case 12: switch (culture) { case LanguageCode.English: // now a bit improved return(EmailType.ChannelTwoConfirmDA); default: return(EmailType.ChannelTwoConfirmDA); } } break; #endregion #region Reset case "Reset": switch (_channelId) { case 1: switch (culture) { case LanguageCode.English: return(EmailType.ChannelOneResetPasswordEn); default: return(EmailType.ChannelOneResetPasswordDa); } case 12: switch (culture) { case LanguageCode.English: return(EmailType.ChannelTwoResetPasswordDA); default: return(EmailType.ChannelTwoResetPasswordDA); } } break; #endregion #region NewAssignUser case "NewAssignUser": switch (_channelId) { case 1: switch (culture) { case LanguageCode.English: return(EmailType.ChannelOneConfirmCategoryPersonEn); default: return(EmailType.ChannelOneConfirmCategoryPersonDa); } case 12: switch (culture) { case LanguageCode.English: return(EmailType.ChannelTwoConfirmCategoryPersonDA); default: return(EmailType.ChannelTwoConfirmCategoryPersonDA); } } break; #endregion #region CustomerOrder case "CustomerOrder": switch (_channelId) { case 1: switch (culture) { case LanguageCode.English: return(EmailType.ChannelOneCustomerOrderEmailEn); default: return(EmailType.ChannelOneCustomerOrderEmailDa); } case 12: switch (culture) { case LanguageCode.English: return(EmailType.ChannelTwoCustomerOrderEmailDA); default: return(EmailType.ChannelTwoCustomerOrderEmailDA); } } break; #endregion #region NewCompany case "NewCompany": switch (_channelId) { case 1: switch (culture) { case LanguageCode.English: return(EmailType.ChannelOneAdminOfNewCompanyEn); default: return(EmailType.ChannelOneAdminOfNewCompanyDa); } case 12: switch (culture) { case LanguageCode.English: return(EmailType.ChannelTwoAdminOfNewCompanyDA); default: return(EmailType.ChannelTwoAdminOfNewCompanyDA); } } break; #endregion #region SupplierLoginRequest case "SupplierLoginRequest": switch (_channelId) { case 1: switch (culture) { case LanguageCode.English: return(EmailType.ChannelOneSupplierLoginRequestEn); default: return(EmailType.ChannelOneSupplierLoginRequestDa); } case 12: switch (culture) { case LanguageCode.English: return(EmailType.ChannelTwoSupplierLoginRequestDA); default: return(EmailType.ChannelTwoSupplierLoginRequestDA); } } break; #endregion #region UserEmail case "UserEmailCommunication": switch (_channelId) { case 1: switch (culture) { case LanguageCode.English: return(EmailType.ChannelOneUserEmailEn); default: return(EmailType.ChannelOneUserEmailDa); } case 12: switch (culture) { case LanguageCode.English: return(EmailType.ChannelTwoUserEmailDA); default: return(EmailType.ChannelTwoUserEmailDA); } } break; #endregion #region OfferRequestOrder case "OfferRequestOrder": switch (_channelId) { case 1: switch (culture) { case LanguageCode.English: return(EmailType.ChannelOneOfferRequestOrderEn); default: return(EmailType.ChannelOneOfferRequestOrderDa); } case 12: switch (culture) { case LanguageCode.English: return(EmailType.ChannelTwoOfferRequestOrderEN); default: return(EmailType.ChannelTwoOfferRequestOrderDA); } } break; #endregion #region InviteUserInCompany case "InviteUserInCompany": switch (_channelId) { case 1: switch (culture) { case LanguageCode.English: return(EmailType.ChannelOneInviteUserInCompanyEn); default: return(EmailType.ChannelOneInviteUserInCompanyDa); } case 12: switch (culture) { case LanguageCode.English: return(EmailType.ChannelTwoInviteUserInCompanyEN); default: return(EmailType.ChannelTwoInviteUserInCompanyDA); } } break; #endregion #region InviteUserInPlatform case "InviteUserInPlatform": switch (_channelId) { case 1: switch (culture) { case LanguageCode.English: return(EmailType.ChannelOneInviteUserInPlatformEn); default: return(EmailType.ChannelOneInviteUserInPlatformDa); } case 12: switch (culture) { case LanguageCode.English: return(EmailType.ChannelTwoInviteUserInPlatformEN); default: return(EmailType.ChannelTwoInviteUserInPlatformDA); } } break; #endregion #region InviteUserInPlatform case "UpdateUserInCompany": switch (_channelId) { case 1: switch (culture) { case LanguageCode.English: return(EmailType.ChannelOneUpdateUserInCompnayEn); default: return(EmailType.ChannelOneUpdateUserInCompanyDa); } case 12: switch (culture) { case LanguageCode.English: return(EmailType.ChannelTwoInviteUserInCompanyEN); default: return(EmailType.ChannelTwoInviteUserInCompanyDA); } } break; #endregion #region BonusLines case "BonusLines": switch (_channelId) { case 1: switch (culture) { case LanguageCode.English: return(EmailType.ChannelOneBonusLinesDa); default: return(EmailType.ChannelOneBonusLinesDa); } case 12: switch (culture) { case LanguageCode.English: return(EmailType.ChannelTwoBonusLinesDA); default: return(EmailType.ChannelTwoBonusLinesDA); } } break; #endregion #region AdminInviteUserEasyOnboarding case "AdminInviteUserEasyOnboarding": return(EmailType.ChannelOneAdminInvitesUsersDa); break; #endregion #region AdminNoInviteUserEasyOnboarding case "AdminNoInviteUserEasyOnboarding": return(EmailType.ChannelOneAdminNoInvitesUsersDa); break; #endregion } return(EmailType.ChannelOneConfirmEn); }