本文整理汇总了C#中StringBuilder.AppendHtmlLine方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuilder.AppendHtmlLine方法的具体用法?C# StringBuilder.AppendHtmlLine怎么用?C# StringBuilder.AppendHtmlLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuilder
的用法示例。
在下文中一共展示了StringBuilder.AppendHtmlLine方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Validate
/// <summary>
/// Validate PaymentInfo Entity
/// </summary>
/// <param name="item">Entity to validate</param>
/// <param name="errorMessage">error message if validation failed</param>
/// <returns>return true if entity passes validation logic, else return false</returns>
public static bool Validate(PaymentInfo item, out string errorMessage)
{
MembershipUser user = Membership.GetUser(item.UserId);
StringBuilder builder = new StringBuilder();
if (user == null)
{
builder.AppendHtmlLine("*UserId must be valid");
}
if (item.CreditCardNumber.IsNullOrWhiteSpace())
{
builder.AppendHtmlLine("*CreditCardNumber is required");
}
if (!item.ExpirationDate.IsValidWithSqlDateStandards())
{
builder.AppendHtmlLine("*ExpirationDate is required and must be valid");
}
if (item.BillingAddress.IsNullOrWhiteSpace())
{
builder.AppendHtmlLine("*Billing Address is required");
}
if (item.CreditCardNumber.Length != 16)
{
builder.AppendHtmlLine("*Credit Card Number must be 16 digits");
}
if (!item.CreditCardNumber.IsNumeric())
{
builder.AppendLine("*Credit Card Number must be a 16 digit number");
}
errorMessage = builder.ToString();
return errorMessage.IsNullOrWhiteSpace();
}
示例2: Validate
/// <summary>
/// Validate PaymentInfo Entity
/// </summary>
/// <param name="item">Entity to validate</param>
/// <param name="errorMessage">error message if vlidation failed</param>
/// <returns>return true if entity passes validation logic, else return false</returns>
public static bool Validate(PaymentInfo item, out string errorMessage)
{
StringBuilder builder = new StringBuilder();
if (item.BillingAddress.IsNullOrWhiteSpace())
{
builder.AppendHtmlLine("*Billing Address is required");
}
if (item.BillingCity.IsNullOrWhiteSpace())
{
builder.AppendHtmlLine("*Billing City is required");
}
if (item.BillingState.IsNullOrWhiteSpace())
{
builder.AppendHtmlLine("*Billing State is required");
}
if (item.BillingZip.IsNullOrWhiteSpace())
{
builder.AppendHtmlLine("*Billing Zip is required");
}
if (item.CCV == default(int))
{
builder.AppendHtmlLine("*CCV is required");
}
if (item.CreditCardNumber.IsNullOrWhiteSpace())
{
builder.AppendHtmlLine("*Credit card number is required");
}
if (item.CreditCardType == EnumCreditCardType.None)
{
builder.AppendHtmlLine("*Credit card type is required");
}
if (!item.ExpirationDate.IsValidWithSqlDateStandards())
{
builder.AppendHtmlLine("*Expiration date is required");
}
if (item.UserId == default(Guid))
{
builder.AppendHtmlLine("*User Id is required");
}
errorMessage = builder.ToString();
return errorMessage.IsNullOrWhiteSpace();
}
示例3: Validate
/// <summary>
/// Validate Paper Entity
/// </summary>
/// <param name="item">Entity to validate</param>
/// <param name="errorMessage">error message if vlidation failed</param>
/// <returns>return true if entity passes validation logic, else return false</returns>
public static bool Validate(Paper item, out string errorMessage)
{
StringBuilder builder = new StringBuilder();
if (item.Author.IsNullOrWhiteSpace())
{
builder.AppendHtmlLine("*Author is required");
}
if (item.Description.IsNullOrWhiteSpace())
{
builder.AppendHtmlLine("*Description is required");
}
if (item.Name.IsNullOrWhiteSpace())
{
builder.AppendHtmlLine("*Name is required");
}
if (item.PaperCategory == EnumPaperCategory.None)
{
builder.AppendHtmlLine("*Paper category is required");
}
if (item.UserId == default(Guid))
{
builder.AppendHtmlLine("*User is required");
}
errorMessage = builder.ToString();
return errorMessage.IsNullOrWhiteSpace();
}
示例4: Validate
/// <summary>
/// Validate Transaction Entity
/// </summary>
/// <param name="item">Entity to validate</param>
/// <param name="errorMessage">error message if validation failed</param>
/// <returns>return true if entity passes validation logic, else return false</returns>
public static bool Validate(Transaction item, out string errorMessage)
{
StringBuilder builder = new StringBuilder();
if (item == null)
{
builder.AppendHtmlLine("*An unexpected error occurred. Please try again");
}
MembershipUser user = Membership.GetUser(item.UserId);
if (user == null)
{
builder.AppendHtmlLine("*UserId must be valid");
}
Inventory inventory = InventoryManager.Load(item.InventoryId);
if (inventory == null)
{
builder.AppendHtmlLine("*InventoryId must be valid");
}
else
{
if (item.IsRentalTransactionInProgress)
{
if (inventory.Quantity == 0)
{
builder.AppendHtmlLine("*The product you selected cannot be rented at this time. Please change your selection and try again.");
}
}
}
if (item.CreditCardNumber.IsNullOrWhiteSpace())
{
builder.AppendHtmlLine("*Credit Card Number is required");
}
else if (item.CreditCardNumber.Length != 16)
{
builder.AppendHtmlLine("*Credit Card Number is invalid");
}
if (!item.ExpirationDate.IsValidWithSqlDateStandards())
{
builder.AppendHtmlLine("*Expiration Date must be valid.");
}
if (!item.TransactionDate.IsValidWithSqlDateStandards())
{
builder.AppendHtmlLine("*Transaction Date must be valid");
}
if (!item.RentalDateStart.IsValidWithSqlDateStandards())
{
builder.AppendHtmlLine("*Rental DateStart must be valid");
}
if (!item.RentalDateEnd.IsValidWithSqlDateStandards())
{
builder.AppendHtmlLine("*Rental Date End must be valid");
}
if (item.RentalDateEnd.OnOrBefore(item.RentalDateStart))
{
builder.AppendHtmlLine("*Rental Date End must be after Rental Date Start");
}
if (!item.TransactionId.HasValue && item.ExpirationDate.Before(DateTime.Today))
{
builder.AppendHtmlLine("*Credit Card must not be expired");
}
if (item.BillingAddress.IsNullOrWhiteSpace())
{
builder.AppendHtmlLine("*BillingAddress is required.");
}
if (item.BillingCity.IsNullOrWhiteSpace())
{
builder.AppendHtmlLine("*BillingCity is required");
}
if (item.BillingState.IsNullOrWhiteSpace())
{
builder.AppendHtmlLine("*BillingState is required");
}
if (item.BillingZip.IsNullOrWhiteSpace())
{
builder.AppendHtmlLine("*BillingZip is required");
}
errorMessage = builder.ToString();
//.........这里部分代码省略.........
示例5: Validate
/// <summary>
/// Validate ConferenceFee Entity
/// </summary>
/// <param name="item">Entity to validate</param>
/// <param name="errorMessage">error message if vlidation failed</param>
/// <returns>return true if entity passes validation logic, else return false</returns>
public static bool Validate(ConferenceFee item, out string errorMessage)
{
StringBuilder builder = new StringBuilder();
if (item.ConferenceId == default(int))
{
builder.AppendHtmlLine("*Please specify the conference to assign this fee to");
}
if (item.FeeAdjustment == EnumFeeAdjustment.None)
{
builder.AppendHtmlLine("*Please specify pricing type for this conference");
}
if (item.FeeType == EnumFeeType.None)
{
builder.AppendHtmlLine("*Please specify the type of fee for this conference");
}
if (item.Multiplier < 0)
{
builder.AppendHtmlLine("*Multiplier must be greater than or equal to 0");
}
if (!item.EffectiveStartDate.IsValidWithSqlDateStandards())
{
builder.AppendHtmlLine("*EffectiveStartDate is not valid with Sql Date Standards.");
}
if (!item.EffectiveEndDate.IsValidWithSqlDateStandards())
{
builder.AppendHtmlLine("*EffectiveEndDate is not valid with Sql Date Standards.");
}
if (item.EffectiveEndDate <= item.EffectiveStartDate)
{
builder.AppendHtmlLine("*Effective End Date needs to be after the Effective Start Date");
}
//Validate Conference
if (builder.ToString().IsNullOrWhiteSpace())
{
SearchConference search = new SearchConference { ConferenceId = item.ConferenceId };
Conference conference = ConferenceManager.Search(search).FirstOrDefault();
if (conference == null)
{
builder.AppendHtmlLine("*Conference Does not exists.");
}
else
{
if (item.EffectiveStartDate.OnOrAfter(conference.StartDate))
{
builder.AppendHtmlLine("*There is a conflict with the Conference Start date.");
}
}
}
//Validate ConferenceFees
if (builder.ToString().IsNullOrWhiteSpace())
{
SearchConferenceFee searchList = new SearchConferenceFee { FeeType = item.FeeType, FeeAdjustment = item.FeeAdjustment, ConferenceId = item.ConferenceId };
List<ConferenceFee> feeList = Search(searchList).Where(t => t.ConferenceFeeId != item.ConferenceFeeId.GetValueOrDefault(0)).ToList();
if (feeList.SafeAny())
{
builder.AppendHtmlLine("*Cannot contain a duplicate Conference Fee Type Entry.");
}
else
{
SearchConferenceFee allSearch = new SearchConferenceFee { FeeType = item.FeeType, ConferenceId = item.ConferenceId };
List<ConferenceFee> allList = Search(allSearch).Where(t => t.ConferenceFeeId != item.ConferenceFeeId.GetValueOrDefault(0)).ToList();
if (allList.SafeAny())
{
if (allList.SafeAny(t => item.EffectiveStartDate.Between(t.EffectiveStartDate, t.EffectiveEndDate) || item.EffectiveEndDate.Between(t.EffectiveStartDate, t.EffectiveEndDate)))
{
builder.AppendHtmlLine("*There is a conflict with the dates for Conference Fee.");
}
if (builder.ToString().IsNullOrWhiteSpace())
{
if (item.FeeAdjustment == EnumFeeAdjustment.Early)
{
if (allList.SafeAny(t => item.EffectiveStartDate.OnOrAfter(t.EffectiveStartDate)))
{
builder.AppendHtmlLine("*Early Fee Type needs to be before Normal or On-Site Fee Type.");
}
}
else if (item.FeeAdjustment == EnumFeeAdjustment.Normal)
{
if (allList.SafeAny(t => item.EffectiveStartDate.OnOrAfter(t.EffectiveStartDate) && t.FeeAdjustment == EnumFeeAdjustment.OnSite))
{
//.........这里部分代码省略.........
示例6: Validate
/// <summary>
/// Validate Special Entity
/// </summary>
/// <param name="item">Entity to validate</param>
/// <param name="errorMessage">error message if validation failed</param>
/// <returns>return true if entity passes validation logic, else return false</returns>
public static bool Validate(Special item, out string errorMessage)
{
StringBuilder builder = new StringBuilder();
Inventory inventory = InventoryManager.Load(item.InventoryId);
if (inventory == null)
{
builder.AppendHtmlLine("*Inventory record must be valid");
}
if (!item.DateStart.IsValidWithSqlDateStandards())
{
builder.AppendHtmlLine("*Date start must be valid");
}
if (!item.DateEnd.IsValidWithSqlDateStandards())
{
builder.AppendHtmlLine("*Date end must be valid");
}
if (item.Price <= 0)
{
builder.AppendHtmlLine("*Price must be greater than zero");
}
if (item.DateStart.After(item.DateEnd))
{
builder.AppendHtmlLine("*Start date must be before end date");
}
if (item.DateEnd.Before(item.DateStart))
{
builder.AppendHtmlLine("*End date must be after start date");
}
List<Special> otherSpecials = LoadByInventoryId(item.InventoryId).Where(dd => dd.SpecialId != item.SpecialId).ToList();
if (
otherSpecials.SafeAny(
dd => DateTimeMethods.DoDatesOverlap(item.DateStart, item.DateEnd, dd.DateStart, dd.DateEnd)))
{
builder.AppendHtmlLine("*Your selection will conflict with at least one other special with the same inventory.");
}
errorMessage = builder.ToString();
return errorMessage.IsNullOrWhiteSpace();
}
示例7: Validate
/// <summary>
/// Validate Transaction Entity
/// </summary>
/// <param name="item">Entity to validate</param>
/// <param name="errorMessage">error message if vlidation failed</param>
/// <returns>return true if entity passes validation logic, else return false</returns>
public static bool Validate(Transaction item, out string errorMessage)
{
StringBuilder builder = new StringBuilder();
PaymentInfo info = TypeMapper<PaymentInfo>.Map(item);
if (!PaymentInfoManager.Validate(info, out errorMessage))
{
builder.AppendHtmlLine(errorMessage);
}
if (item.Fee == default(decimal))
{
builder.AppendHtmlLine("*Fee is required");
}
if (item.FeeAdjustment == EnumFeeAdjustment.None)
{
builder.AppendHtmlLine("*Fee adjustment is required");
}
if (item.FeeType == EnumFeeType.None)
{
builder.AppendHtmlLine("*Fee type is required");
}
if (!item.TransactionDate.IsValidWithSqlDateStandards())
{
builder.AppendHtmlLine("*Transaction date is required");
}
if (item.UserId == default(Guid))
{
builder.AppendHtmlLine("*User Id is required");
}
errorMessage = builder.ToString();
return errorMessage.IsNullOrWhiteSpace();
}