public Validation ValidateNewBidder(Bidder bidder, ref IAuctionTransaction trans) { var val = new Validation(); if (string.IsNullOrEmpty(bidder.Name)) { val.AddError("Name is empty"); } if (string.IsNullOrEmpty(bidder.Phone)) { val.AddError("Phone number is empty"); } else if (!PhoneNumberIsFormattedCorrectly(bidder.Phone)) { val.AddError("Phone number is not in the correct format"); } if (!_eventRepo.EventExists(bidder.EventId, ref trans)) { val.AddError("Must be in valid auction"); } return val; }
public Validation ValidateNewDonor(Donor donor) { IAuctionTransaction trans = null; var val = new Validation(); if (string.IsNullOrEmpty(donor.Name)) { val.AddError("Name is empty"); } if (string.IsNullOrEmpty(donor.Address)) { val.AddError("Address is empty"); } if (string.IsNullOrEmpty(donor.Phone)) { val.AddError("Phone is empty"); } if (donor.AccountId == 0) { val.AddError("Account is not set"); } else if (_accountRepo.AccountExists(donor.AccountId, ref trans)) { val.AddError("Not set to a valid Account"); } return val; }
public Validation ValidateExistingBidder(Bidder bidder, ref IAuctionTransaction trans) { var val = new Validation(); if (bidder.Id <= 0) { val.AddError("Bidder must have an id"); } if (string.IsNullOrEmpty(bidder.Name)) { val.AddError("Name is empty"); } if (string.IsNullOrEmpty(bidder.Phone)) { val.AddError("Phone number is empty"); } else if (!PhoneNumberIsFormattedCorrectly(bidder.Phone)) { val.AddError("Phone number is not in the correct format"); } if (!_eventRepo.EventExists(bidder.EventId, ref trans)) { val.AddError("Must be in valid auction"); } else { if (bidder.Id > 0) { var bidderInSystem = _bidderRepo.GetByNumberAndEvent(bidder.Number, bidder.EventId, ref trans); if (bidderInSystem.Id != bidder.Id) { val.AddError("Invalid bidder number"); } } } return val; }