本文整理汇总了C#中ValidationResults.AddResult方法的典型用法代码示例。如果您正苦于以下问题:C# ValidationResults.AddResult方法的具体用法?C# ValidationResults.AddResult怎么用?C# ValidationResults.AddResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ValidationResults
的用法示例。
在下文中一共展示了ValidationResults.AddResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EntityValidation
public void EntityValidation(ValidationResults results)
{
//--- Required
if (bill_of_material_head_id == null)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Bill Of Material Head"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (IsCheckedMaterial && material_id == null)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Material"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
else if (!IsCheckedMaterial && bill_of_material_head_id_sub == null)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "BOM"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (amount == null)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Amount"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (lost_factor == null)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Lost Factor"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
}
示例2: EntityValidation
public void EntityValidation(ValidationResults results)
{
//--- Required
if (string.IsNullOrEmpty(employee_no))
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Employee No"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (string.IsNullOrEmpty(first_name))
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "First Name"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (string.IsNullOrEmpty(last_name))
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Last Name"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (string.IsNullOrEmpty(user_name))
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "User Name"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (string.IsNullOrEmpty(user_password))
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Password"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
}
示例3: EntityValidation
public void EntityValidation(ValidationResults results)
{
//--- Required
if (menu_id == null)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Menu"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (bill_of_material_head_id == null)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Bill of Material Head"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (quantity == null)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Quantity"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
//---
if (quantity <= 0)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.CompareValueMore, "Quantity", 0), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
}
示例4: ValidateCourseCanOnlyBeChoosenASingleTime
/// <summary>
/// Un curs poate fi ales cel mult o data de catre un student.
/// </summary>
/// <param name="student"></param>
/// <param name="results"></param>
internal void ValidateCourseCanOnlyBeChoosenASingleTime(Student student, ValidationResults results)
{
if (student.Courses.Where(c => c.CourseId != 0).GroupBy(c => c.CourseId).Any(g => g.Count() > 1))
{
results.AddResult(new ValidationResult
(
"The there are duplicate courses (same id) in the list of courses chosen by the student", results, "ValidationMethod", "error", null)
);
return;
}
if (student.Courses.Where(c => c.CourseId != 0).GroupBy(c => new { c.Name, c.Description }).Any(g => g.Count() > 1))
{
results.AddResult(new ValidationResult
(
"The there are duplicate courses (same name & description) in the list of courses chosen by the student", results, "ValidationMethod", "error", null)
);
return;
}
if (student.Courses.Where(c => c.CourseId != 0).GroupBy(c => c.Name).Any(g => g.Count() > 1))
{
results.AddResult(new ValidationResult
(
"The there are duplicate courses in the list of courses (same name) chosen by the student", results, "ValidationMethod", "error", null)
);
}
}
示例5: ValidationResultsWithMultipleFailureResultsIsFail
public void ValidationResultsWithMultipleFailureResultsIsFail()
{
ValidationResults validationResults = new ValidationResults();
validationResults.AddResult(new ValidationResult("message1", null, null, null, null));
validationResults.AddResult(new ValidationResult("message2", null, null, null, null));
Assert.IsFalse(validationResults.IsValid);
}
示例6: ReturnsActualResultsCount
public void ReturnsActualResultsCount()
{
ValidationResults validationResults = new ValidationResults();
Assert.AreEqual(0, validationResults.Count);
validationResults.AddResult(new ValidationResult("message1", null, null, null, null));
Assert.AreEqual(1, validationResults.Count);
validationResults.AddResult(new ValidationResult("message2", null, null, null, null));
Assert.AreEqual(2, validationResults.Count);
}
示例7: EntityValidation
public void EntityValidation(ValidationResults results)
{
//--- Required
if (string.IsNullOrEmpty(bill_of_material_group_code))
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Bill Of Material Group Code"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (string.IsNullOrEmpty(bill_of_material_group_name))
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Bill Of Material Group Name"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
}
示例8: CanEnumerateThroughNonGenericEnumeratorInterface
public void CanEnumerateThroughNonGenericEnumeratorInterface()
{
ValidationResults validationResults = new ValidationResults();
validationResults.AddResult(new ValidationResult("message1", null, null, null, null));
validationResults.AddResult(new ValidationResult("message2", null, null, null, null));
IEnumerator enumerator = (validationResults as IEnumerable).GetEnumerator();
Assert.IsTrue(enumerator.MoveNext());
Assert.AreEqual("message1", ((ValidationResult)enumerator.Current).Message);
Assert.IsTrue(enumerator.MoveNext());
Assert.AreEqual("message2", ((ValidationResult)enumerator.Current).Message);
Assert.IsFalse(enumerator.MoveNext());
}
示例9: EntityValidation
public void EntityValidation(ValidationResults results)
{
//--- Required
if (string.IsNullOrEmpty(menu_code))
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Menu Code"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (string.IsNullOrEmpty(menu_name))
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Menu Name"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
}
示例10: CanGetTextualRepresentationForExceptionWithMultipleValidationResults
public void CanGetTextualRepresentationForExceptionWithMultipleValidationResults()
{
var results = new ValidationResults();
results.AddResult(new ValidationResult("message1", null, null, null, null));
results.AddResult(new ValidationResult("message2", null, "the key", null, null));
results.AddResult(new ValidationResult("message3", null, null, null, null));
var exception = new ArgumentValidationException(results, "param");
var toString = exception.ToString();
Assert.IsNotNull(toString);
Assert.IsTrue(toString.Contains("message1"));
Assert.IsTrue(toString.Contains("message2"));
Assert.IsTrue(toString.Contains("message3"));
}
示例11: EntityValidation
public void EntityValidation(ValidationResults results)
{
//--- Required
if (string.IsNullOrEmpty(material_code))
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Material Code"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (string.IsNullOrEmpty(material_name))
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Material Name"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (uom_id_receive == 0)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "UOM Receive"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (uom_id_count == 0)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "UOM Count"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (uom_id_use == 0)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "UOM Use"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (max_stock == 0)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Maximum Stock"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (min_stock == 0)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Minimum Stock"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (shelf_life == 0)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Shelf Life"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (material_cost == 0)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Material Cost"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (acceptable_variance == 0)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Acceptable Variance"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
if (material_group_id == 0)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Material Group"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
}
示例12: Validate
public void Validate(ValidationResults results)
{
if (string.IsNullOrEmpty(this.control_code) && this.control_parent_id == null)
{
ValidationResult result = new ValidationResult(ErrorMessage.ScreenCodeIsRequire, this, string.Empty, string.Empty, null);
results.AddResult(result);
}
List<DuplicateItemDTO> listDuplicateItemDTO = ServiceProvider.ScreenConfigService.IsDuplication(this);
if (listDuplicateItemDTO.Where(item => item.isDuplicate == true).FirstOrDefault() != null)
{
ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsDuplicate, "Screen Code"), this, string.Empty, string.Empty, null);
results.AddResult(result);
}
}
示例13: ControlValidationMappingsFailureTest
public void ControlValidationMappingsFailureTest()
{
IBugzillaPageView viewMock = MockRepository.StrictMock<IBugzillaPageView>();
Expect.Call(viewMock.Model).PropertyBehavior();
viewMock.ValidationRequested += null;
LastCall.IgnoreArguments();
viewMock.ControlValidationTriggered += null;
LastCall.IgnoreArguments();
IEventRaiser raiser = LastCall.GetEventRaiser();
Expect.Call(FacadeMock.GetSourceList()).Return(new string[0]);
Expect.Call(viewMock.SourceList).PropertyBehavior().Return(new string[0]);
Expect.Call(FacadeMock.GetProjectWrapperList()).Return(null);
Expect.Call(viewMock.VersionOneProjects).PropertyBehavior();
Expect.Call(FacadeMock.GetVersionOnePriorities()).Return(null);
Expect.Call(viewMock.VersionOnePriorities).PropertyBehavior();
viewMock.DataBind();
ValidationResults results = new ValidationResults();
ValidationResult generalResult = new ValidationResult(string.Empty, new BugzillaProjectMapping(), null, null, null);
results.AddResult(generalResult);
Expect.Call(FacadeMock.ValidateEntity(viewMock.Model)).IgnoreArguments().Return(results);
viewMock.SetGeneralTabValid(true);
viewMock.SetMappingTabValid(false);
MockRepository.ReplayAll();
BugzillaController controller = CreateController();
controller.RegisterView(viewMock);
controller.PrepareView();
raiser.Raise(viewMock, EventArgs.Empty);
MockRepository.VerifyAll();
}
示例14: DoValidateSubmit
public void DoValidateSubmit(ValidationResults results)
{
if (this.Modes.Count == 0)
results.AddResult(new ValidationResult("At least one ground transportation mode is required.",
typeof(Ground),
"", "", null));
}
示例15: Validate
public void Validate(ValidationResults results)
{
string msg = string.Empty;
if (!DateDue.HasValue)
{
if (OnOrder > 0)
{
msg = "Must provide a delivery due date for stock on back order.";
results.AddResult(new ValidationResult(msg, this, "ProductSelfValidation", "", null));
}
}
else
{
if (OnOrder == 0)
{
msg = "Can specify delivery due date only when stock is on back order.";
results.AddResult(new ValidationResult(msg, this, "ProductSelfValidation", "", null));
}
}
if (InStock + OnOrder > 100)
{
msg = "Total inventory (in stock and on order) cannot exceed 100 items.";
results.AddResult(new ValidationResult(msg, this, "ProductSelfValidation", "", null));
}
}