private Artist GetArtist(CreatePieceModel model) { Artist artist = null; if (model.ArtistId >= 0) { artist = repository.GetArtist(model.ArtistId.Value); } else if (model.ArtistId < 0 && !string.IsNullOrWhiteSpace(model.ArtistName)) { Country artistCountryOfOrigin = null; if (model.ArtistCountryOfOriginId.HasValue) { artistCountryOfOrigin = repository.GetCountry(model.ArtistCountryOfOriginId.Value); } artist = artistFactory.Create( model.ArtistName, model.ArtistAlsoKnownAs, model.ArtistCityOfOrigin, model.ArtistStateOfOrigin, artistCountryOfOrigin, model.ArtistBirthDate, model.ArtistDeathDate, model.MuseumId); repository.AddArtist(artist); } return(artist); }