Either <Error, SupplierDto> SetCountry(SupplierDto supplier) { var country = _countryRepository.FromCountryId(supplier.SelectedCountry); if (country == null) { return(Error.New("couldn't find to country")); } var nSupplier = supplier with { Country = country }; return(nSupplier); } Either <Error, SupplierDto> SetPaymentTerm(SupplierDto dto) => _paymentTermRepository.Find(dto.PaymentTermId) .Match(p => Right(dto with { PaymentTerm = FromEntity(p) }) , () => Left <Error, SupplierDto>(Error.New("couldn't find payment term selected"))); Either <Error, Supplier> UpdateEntity(SupplierDto dto, Supplier supplier) { var code = new Code(dto.Code); var name = new Name(dto.Name); var email = new Email(dto.Email ?? string.Empty); var phone = new Phone(dto.Phone ?? string.Empty); supplier.EditSupplier(code , name , email , phone , dto.SupplierGroup , FromDto(dto.PaymentTerm) , new GeneralText(dto.Notes) , dto.IsIndependent , dto.Rnc , dto.HomeOrApartment , dto.City , dto.Street , dto.Country , supplier.Status); return(supplier); } }
public Country FromCountryId(int id) => _countryRepository.FromCountryId(id);