public void DeleteMapComponentForYear(int mapcomponentId, int yearId) { MapComponent mapcomponent = u_repo.GetMapComponent(mapcomponentId); MapComponentYears mapcompyear = mapcomponent.MapComponentYears.SingleOrDefault(t => t.YearsId == yearId); if (mapcomponent == null) { throw new MapException(Properties.Settings.Default.ExceptionMapComponentInvalid); } if (mapcompyear.Answers.HasAny() || mapcompyear.Fates.HasAny() || !mapcompyear.Comments.IsNullOrWhiteSpace()) { throw new MapException(Properties.Settings.Default.ExceptionMapComponentYear); } u_repo.DeleteMapComponentYear(mapcompyear); }