public IEnumerable<ErrorMessage> Validate(WineDTO wine) { var entity = wine.To(); var validator = new ValidateWine(entity.Name, entity.Kind.ToMaybe(), entity.Producer.ToMaybe(), entity.Alcohol); var uniqueness = new UniquenessConstraint<Wine>(() => validator.Commit()); return validator.Errors.Union(uniqueness.Errors); }
public static WineDTO From(Wine wine) { var dto = new WineDTO(); dto.Name = wine.Name; dto.Kind = KindDTO.From(wine.Kind); dto.Producer = ProducerDTO.From(wine.Producer); dto.Alcohol = wine.Alcohol; return dto; }