private void ImportMunicipality(Municipality municipalityToAdd) { var existingMunicipality = _municipalityRepo.Get(municipalityToAdd.Name); if (existingMunicipality == null) { _municipalityRepo.Add(municipalityToAdd); existingMunicipality = new Municipality { Id = municipalityToAdd.Id }; } ImportMunicipalityTaxes(existingMunicipality, municipalityToAdd.Taxes); }
public bool Create(string manucipality) { try { _municipalityRepo.Add(new Municipality { Name = manucipality }); _municipalityRepo.Save(); return(true); } catch { return(false); } }
public async Task <(Municipality addedMunicipality, string error)> AddAsync(string name) { if (await _municipalityRepository.Exist(name)) { return(null, Messages.SameMunicipalityExist); } var municipality = new Municipality { Name = name }; _municipalityRepository.Add(municipality); await _unitOfWork.CommitAsync(); return(municipality, null); }
/// <summary> /// The Save /// </summary> /// <param name="entity">The entity<see cref="Municipality"/></param> /// <returns>The <see cref="ServiceResult"/></returns> public ServiceResult Save(Municipality entity) { try { if (entity.Identifier == 0) { _repository.Add(entity); } else { _repository.Update(entity); } return(new ServiceResult(true)); } catch (Exception ex) { return(new ServiceResult(false) { Error = ex.ToString() }); } }