Exemple #1
0
 public static TaxRegimeTypeViewModel FromDto(TaxRegimeDto taxRegimeType)
 => new TaxRegimeTypeViewModel()
 {
     Id          = taxRegimeType.Id,
     Name        = taxRegimeType.Name,
     Description = taxRegimeType.Description
 };
Exemple #2
0
 Either <Error, TaxRegimeDto> ValidateIsCorrectUpdate(long id, TaxRegimeDto taxRegimeDto)
 {
     if (id == taxRegimeDto.Id)
     {
         return(taxRegimeDto);
     }
     return(Error.New("Invalid update entity id"));
 }
Exemple #3
0
 Either <Error, TaxRegimeType> UpdateEntity(TaxRegimeDto taxRegimeDto, TaxRegimeType taxRegime)
 {
     taxRegime.EditTaxRegimeType(new Name(taxRegimeDto.Name), new GeneralText(taxRegimeDto.Description));
     return(taxRegime);
 }
Exemple #4
0
 Either <Error, TaxRegimeType> CreateEntity(TaxRegimeDto taxRegimeDto)
 => Right <Error, TaxRegimeType>(taxRegimeDto);
Exemple #5
0
 Either <Error, TaxRegimeDto> ValidateName(TaxRegimeDto taxRegimeDto)
 => Name.Of(taxRegimeDto.Name).Match(Succ: c => taxRegimeDto,
                                     Fail: err => Left <Error, TaxRegimeDto>(Error.New(string.Join(";", err))));
Exemple #6
0
 public Either <Error, TaxRegimeType> Update(long id, TaxRegimeDto taxDto)
 => ValidateIsCorrectUpdate(id, taxDto)
 .Bind(ValidateName)
 .Bind(c => Find(c.Id))
 .Bind(c => UpdateEntity(taxDto, c))
 .Bind(Save);
Exemple #7
0
 public Either <Error, TaxRegimeType> Create(TaxRegimeDto taxRegimeDto)
 => ValidateName(taxRegimeDto)
 .Bind(CreateEntity)
 .Bind(Add)
 .Bind(Save);