public async override Task <ValidationResult> Validate(Guid?activityResultID) { var errors = new StringBuilder(); if (activityResultID == null) { errors.AppendHtmlLine(CommonMessages.ActivityResultIDRequired); } var permissions = await db.GetGrantedWorkflowActivityPermissionsForRequestAsync(_workflow.Identity, _entity, PermissionIdentifiers.ProjectRequestTypeWorkflowActivities.CloseTask); var allowApproveRejectSubmission = await ApproveRejectSubmission(); if (!permissions.Contains(PermissionIdentifiers.ProjectRequestTypeWorkflowActivities.CloseTask) || !allowApproveRejectSubmission) { errors.AppendHtmlLine(CommonMessages.RequirePermissionToApproveOrRejectRequestSubmission); } if (errors.Length > 0) { return(new ValidationResult { Success = false, Errors = errors.ToString() }); } else { return(new ValidationResult { Success = true }); } }
public void AppendHtmlLine_WithEmptyStringBuilder() { // Arrange var componentUnderTest = new StringBuilder(); var expected = $"{Environment.NewLine}<br />{Environment.NewLine}"; // Act componentUnderTest.AppendHtmlLine(); // Assert componentUnderTest.ToString().ShouldHaveSameValueAs(expected); }
private void dowork(object o, DoWorkEventArgs args) { BackgroundWorker b = o as BackgroundWorker; StringBuilder sb = new StringBuilder(); var finder = new UPnPDeviceFinder(); var foundDevices = new List <UPnPDevice>(); var deviceType = "upnp:rootdevice"; var devices = finder.FindByType(deviceType, 1); foreach (UPnPDevice upnpDevice in devices) { sb.AppendHtmlLine("FriendlyName: " + upnpDevice.FriendlyName); sb.AppendHtmlLine("Description: " + upnpDevice.Description); sb.AppendHtmlLine("PresentationURL: " + upnpDevice.PresentationURL); string port = new Uri(upnpDevice.PresentationURL).Port.ToString(); string baseUrl = new Uri(upnpDevice.PresentationURL).DnsSafeHost.ToString(); sb.AppendHtmlLine("Type: " + upnpDevice.Type); sb.AppendHtmlLine("Port: " + port); sb.AppendHtmlLine("baseUrl: " + baseUrl); sb.AppendLine("<hr/>"); } WebPage.DisplayWebPage("Universal Plug and Play devices", sb.ToString()); }
public override async Task <ValidationResult> Validate(Guid?activityResultID) { if (activityResultID == null) { return(new ValidationResult { Success = false, Errors = CommonMessages.ActivityResultIDRequired }); } var permissions = await db.GetGrantedWorkflowActivityPermissionsForRequestAsync(_workflow.Identity, _entity); if (!permissions.Contains(PermissionIdentifiers.ProjectRequestTypeWorkflowActivities.EditTask) && (activityResultID.Value == SaveResultID || activityResultID.Value == ModifyResultID)) { return(new ValidationResult { Success = false, Errors = CommonMessages.RequirePermissionToEditTask }); } if (!permissions.Contains(PermissionIdentifiers.ProjectRequestTypeWorkflowActivities.CloseTask) && (activityResultID.Value == SubmitResultID)) { return(new ValidationResult { Success = false, Errors = CommonMessages.RequirePermissionToCloseTask }); } if (!permissions.Contains(PermissionIdentifiers.ProjectRequestTypeWorkflowActivities.CloseTask) && (activityResultID.Value == TerminateResultID)) { return(new ValidationResult { Success = false, Errors = CommonMessages.RequirePermissionToTerminateWorkflow }); } var errors = new StringBuilder(); if (activityResultID.Value == SubmitResultID) { if (_entity.ProjectID == null) { errors.AppendHtmlLine("Please ensure that you have selected a project for the request."); } if (_entity.DueDate.HasValue && _entity.DueDate.Value < DateTime.UtcNow) { errors.AppendHtmlLine("The Request Due Date must be set in the future."); } var dataMartsDueDate = false; foreach (var dm in _entity.DataMarts) { if (dm.DueDate.HasValue && dm.DueDate.Value.Date < DateTime.UtcNow.Date) { dataMartsDueDate = true; } } if (dataMartsDueDate) { errors.AppendHtmlLine("The Request's DataMart Due Dates must be set in the future."); } if (_entity.SubmittedOn.HasValue) { errors.AppendHtmlLine("Cannot submit a request that has already been submitted"); } if (_entity.Template) { errors.AppendHtmlLine("Cannot submit a request template"); } if (_entity.Scheduled) { errors.AppendHtmlLine("Cannot submit a scheduled request"); } await db.LoadReference(_entity, (r) => r.Project); //If a project loaded successfully check it. if (_entity.Project != null) { if (!_entity.Project.Active || _entity.Project.Deleted) { errors.AppendHtmlLine("Cannot submit a request for an inactive or deleted project."); } if (_entity.Project.EndDate < DateTime.UtcNow) { errors.AppendHtmlLine("Cannot submit a request for a project that has ended."); } await db.LoadCollection(_entity.Project, (p) => p.DataMarts); if (_entity.DataMarts.Any(dm => !_entity.Project.DataMarts.Any(pdm => pdm.DataMartID == dm.DataMartID))) { errors.AppendHtmlLine("The request contains datamarts that are not part of the project specified and thus cannot be processed. Please remove these datamarts and try again."); } } await db.LoadCollection(_entity, (r) => r.DataMarts); var dataMarts = _entity.GetGrantedDataMarts(db, _workflow.Identity); if (_entity.DataMarts.Any(dm => !dataMarts.Any(gdm => gdm.ID == dm.DataMartID))) { errors.AppendHtmlLine("This request contains datamarts you are not permitted to submit to. Please remove them and try again."); } var filters = new ExtendedQuery { Projects = (a) => a.ProjectID == _entity.ProjectID, ProjectOrganizations = a => a.ProjectID == _entity.ProjectID && a.OrganizationID == _entity.OrganizationID, Organizations = a => a.OrganizationID == _entity.OrganizationID, Users = a => a.UserID == _entity.CreatedByID }; if (_entity.DataMarts.Count < 2) { var skip2DataMartRulePerms = await db.HasGrantedPermissions <Request>(_workflow.Identity, _entity, filters, PermissionIdentifiers.Portal.SkipTwoDataMartRule); if (!skip2DataMartRulePerms.Contains(PermissionIdentifiers.Portal.SkipTwoDataMartRule)) { errors.AppendHtmlLine("Cannot submit a request with less than 2 datamarts"); } } } if (errors.Length > 0) { return(new ValidationResult { Success = false, Errors = errors.ToString() }); } else { return(new ValidationResult { Success = true }); } }
/// <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(); }
/// <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(); }
/// <summary> /// Performs common submit validation of a request. /// </summary> /// <returns>Any error messages, empty if valid.</returns> protected async Task <string> PerformSubmitValidation() { var errors = new StringBuilder(); if (_entity.ProjectID == null) { errors.AppendHtmlLine("Please ensure that you have selected a project for the request."); } if (_entity.DueDate.HasValue && _entity.DueDate.Value < DateTime.UtcNow) { errors.AppendHtmlLine("The Request Due Date must be set in the future."); } var dataMartsDueDate = false; foreach (var dm in _entity.DataMarts) { if (dm.DueDate.HasValue && dm.DueDate.Value.Date < DateTime.UtcNow.Date) { dataMartsDueDate = true; } } if (dataMartsDueDate) { errors.AppendHtmlLine("The Request's DataMart Due Dates must be set in the future."); } if (_entity.SubmittedOn.HasValue && _entity.Status != Lpp.Dns.DTO.Enums.RequestStatuses.RequestRejected) //Rejected requests can be re-submitted. { errors.AppendHtmlLine("Cannot submit a request that has already been submitted"); } if (_entity.Template) { errors.AppendHtmlLine("Cannot submit a request template"); } if (_entity.Scheduled) { errors.AppendHtmlLine("Cannot submit a scheduled request"); } await db.LoadReference(_entity, (r) => r.Project); await db.LoadCollection(_entity, (r) => r.DataMarts); //If a project loaded successfully check it. if (_entity.Project != null) { if (!_entity.Project.Active || _entity.Project.Deleted) { errors.AppendHtmlLine("Cannot submit a request for an inactive or deleted project."); } if (_entity.Project.EndDate < DateTime.UtcNow) { errors.AppendHtmlLine("Cannot submit a request for a project that has ended."); } await db.LoadCollection(_entity.Project, (p) => p.DataMarts); if (_entity.DataMarts.Any(dm => !_entity.Project.DataMarts.Any(pdm => pdm.DataMartID == dm.DataMartID))) { errors.AppendHtmlLine("The request contains datamarts that are not part of the project specified and thus cannot be processed. Please remove these datamarts and try again."); } } var dataMarts = await GetAllAvailableDataMarts(); if (_entity.DataMarts.Any(dm => !dataMarts.Any(gdm => gdm == dm.DataMartID))) { errors.AppendHtmlLine("This request contains datamarts you are not permitted to submit to. Please remove them and try again."); } var filters = new ExtendedQuery { Projects = (a) => a.ProjectID == _entity.ProjectID, ProjectOrganizations = a => a.ProjectID == _entity.ProjectID && a.OrganizationID == _entity.OrganizationID, Organizations = a => a.OrganizationID == _entity.OrganizationID, Users = a => a.UserID == _entity.CreatedByID }; if (_entity.DataMarts.Count < 2) { var skip2DataMartRulePerms = await db.HasGrantedPermissions <Request>(_workflow.Identity, _entity, filters, PermissionIdentifiers.Portal.SkipTwoDataMartRule); if (!skip2DataMartRulePerms.Contains(PermissionIdentifiers.Portal.SkipTwoDataMartRule)) { errors.AppendHtmlLine("Cannot submit a request with less than 2 datamarts"); } } return(errors.ToString()); }
/// <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(); }
override public bool Execute(string[] args) { string text = Clipboard.GetText(); string formatText = ""; string delimiter = "word"; if (args.Length > 1 && !string.IsNullOrWhiteSpace(args[1])) { formatText = args[1]; } if (args.Length > 2 && !string.IsNullOrWhiteSpace(args[2])) { if (string.Compare(args[2].Trim(), "line", true) == 0) { delimiter = "line"; } else if (string.Compare(args[2].Trim(), "tab", true) == 0) { delimiter = "tab"; } } if (!string.IsNullOrWhiteSpace(text)) { StringBuilder sb = new StringBuilder(); List <string> lines = text.SplitLines(); StringBuilder errorText = new StringBuilder(); foreach (var line in lines) { try { if (delimiter == "word") { string cleanline = line.Trim(); string[] words = cleanline.Split(' '); for (int i = 0; i < words.Length; i++) { words[i] = words[i].Trim(); } sb.AppendLine(string.Format(formatText, words)); } else if (delimiter == "tab") { string[] words = line.Split('\t'); for (int i = 0; i < words.Length; i++) { words[i] = words[i].Trim(); } sb.AppendLine(string.Format(formatText, words)); } else if (delimiter == "line") { sb.AppendLine(string.Format(formatText, line)); } } catch (Exception e) { string errorMessage = $"Format failed this line '{line}' for delimiter {delimiter} and format string {formatText} with error '{e.Message}'"; errorText.AppendHtmlLine(errorMessage); } } if (errorText.Length > 0) { WebPage.DisplayWebPage("Format Command Error", formatText + "<hr/>" + errorText.ToString()); } try { Clipboard.SetText(sb.ToString(), TextDataFormat.Text); } catch (Exception) { } } return(true); // hide command window }
/// <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(); return errorMessage.IsNullOrWhiteSpace(); }
public static string Environment() { var sb = new StringBuilder(); sb.AppendHtmlLine($"Environment:{Stage}"); try { sb.AppendHtmlLine($"Domain: {Domain}"); sb.AppendHtmlLine($"Url: {Url}"); sb.AppendHtmlLine($"Machine Name: {System.Environment.MachineName}"); sb.AppendHtmlLine($"Server IP Address: {ServerIPAddress()}"); sb.AppendHtmlLine($"Client IP Address: {ClientIPAddress()}"); sb.AppendHtmlLine($"Assembly Version: {AssemblyVersion}"); sb.AppendHtmlLine($"File Version: {FileVersion()}"); sb.AppendHtmlLine($"Umbraco CMS Version: {UmbracoVersion.SemanticVersion.ToSemanticString()}"); sb.AppendHtmlLine($"Application Physical Path: {HostingEnvironment.ApplicationPhysicalPath}"); sb.AppendHtmlLine($"ApplicationID: {HostingEnvironment.ApplicationID}"); sb.AppendHtmlLine($"Environment Variable %temp%: {System.Environment.ExpandEnvironmentVariables("%temp%")}"); sb.AppendHtmlLine(String.Empty); } catch (Exception ex) { sb.AppendHtmlLine($"Exception:{ex.Message}"); }; return(sb.ToString()); }
/// <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)) { builder.AppendHtmlLine("*Normal Fee Type needs to be before On-Site Fee Type."); } else if (allList.SafeAny(t => item.EffectiveStartDate.OnOrBefore(t.EffectiveEndDate) && t.FeeAdjustment == EnumFeeAdjustment.Early)) { builder.AppendHtmlLine("*Normal Fee Type needs to be after Early Fee Type."); } } else if (item.FeeAdjustment == EnumFeeAdjustment.OnSite) { if (allList.SafeAny(t => item.EffectiveStartDate.OnOrBefore(t.EffectiveEndDate))) { builder.AppendHtmlLine("*On-Site Fee Type needs to be after Normal or Early Fee Type."); } } } } } } errorMessage = builder.ToString(); return errorMessage.IsNullOrWhiteSpace(); }
/// <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(); }
/// <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(); }