public NameMunicipality( NisCode nisCode, MunicipalityName name) { NisCode = nisCode; Name = name; }
public MunicipalityNameWasCorrected( MunicipalityId municipalityId, MunicipalityName municipalityName) { MunicipalityId = municipalityId; Language = municipalityName.Language; Name = municipalityName.Name; }
public MunicipalityWasNamed( MunicipalityId municipalityId, MunicipalityName municipalityName) { MunicipalityId = municipalityId; Language = municipalityName.Language; Name = municipalityName.Name; }
public void Name(MunicipalityName name) { if (string.IsNullOrWhiteSpace(name)) { throw new NoNameException("Cannot give a municipality an empty name."); } ApplyChange(new MunicipalityWasNamed(_municipalityId, name)); }
private void CheckChangedName(Language?language, string name, CrabModification?modification) { if (string.IsNullOrWhiteSpace(name)) { throw new NoNameException("Cannot give a municipality an empty name."); } // TODO: Wat als language null is? Primary language? if (!language.HasValue) { return; } var newMunicipalityName = new MunicipalityName(name, language.Value); // We dont have this language yet, and it is actually filled in // We dont care about empty languages which we dont know yet anyway if (!_names.ContainsKey(language.Value) && !string.IsNullOrWhiteSpace(name)) { if (modification == CrabModification.Correction) { ApplyChange(new MunicipalityNameWasCorrected(_municipalityId, newMunicipalityName)); } else { Name(newMunicipalityName); } } // We already have this language, and it got cleared else if (_names.ContainsKey(language.Value) && string.IsNullOrWhiteSpace(name)) { if (modification == CrabModification.Correction) { ApplyChange(new MunicipalityNameWasCorrectedToCleared(_municipalityId, language.Value)); } else { ClearName(language.Value); } } // We already have this language, and it got changed else if (_names.ContainsKey(language.Value) && _names[language.Value] != newMunicipalityName) { if (modification == CrabModification.Correction) { ApplyChange(new MunicipalityNameWasCorrected(_municipalityId, newMunicipalityName)); } else { Name(newMunicipalityName); } } // We dont care if it didnt change }
public Tax AsTax(IEnumerable <Municipality> municipalities) { var tax = new Tax { Id = Id ?? 0, Municipality_Id = MunicipalityId ?? 0, TaxType = TaxType, StartDate = StartDate, EndDate = EndDate, Amount = Convert.ToSingle(Amount) }; if (tax.Municipality_Id == 0 && !string.IsNullOrWhiteSpace(MunicipalityName) && municipalities != null) { var m = municipalities.FirstOrDefault(municipality => municipality.Name.ToLower() == MunicipalityName.ToLower()); if (m != null) { tax.Municipality_Id = m.Id; tax.Municipality = m; } } return(tax); }