public IEnumerable <Sanction> GetAllActive() { using (var context = new EduhubContext(_connectionString)) { var sanctionDto = context.Sanctions.Where(s => s.IsActive).ToList(); var result = new List <Sanction>(); sanctionDto.ForEach(dto => result.Add(SanctionExtensions.ParseFromSanctionDto(dto))); return(result); } }
public Sanction Get(int id) { using (var context = new EduhubContext(_connectionString)) { var sanctionDto = context.Sanctions .FirstOrDefault(s => s.Id == id); Ensure.Any.IsNotNull(sanctionDto, nameof(sanctionDto), opt => opt.WithException(new SanctionNotFoundException(id))); var result = SanctionExtensions.ParseFromSanctionDto(sanctionDto); return(result); } }