Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. public class OfficeCheckInVerification : ValidationAttribute
  2. {
  3. protected override ValidationResult IsValid(object value, ValidationContext validationContext)
  4. {
  5. var movement = (OfficeCheckInCreateRequest) validationContext.ObjectInstance;
  6.  
  7. if (movement.MainVehicleId.Equals(movement.SecondaryVehicleId))
  8. return new ValidationResult("Vehicles can't be the same");
  9.  
  10. if (movement.OriginId.Equals(movement.DestinationId))
  11. return new ValidationResult("Origin Can't Be The Same as Destination");
  12.  
  13. if (!movement.EndTime.CompareTo(movement.StartTime).Equals(1))
  14. return new ValidationResult("Ending time must be greater than starting time");
  15.  
  16. return base.IsValid(value, validationContext);
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement