示例#1
0
 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);
 }
示例#2
0
 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;
 }