// TODO: Figure out how to map filters from domain to EF
        //public DataResult<List<Organization>> GetAllWhereAsync(
        //        Expression<Func<EfOrganization, bool>> filterFunc)
        //{
        //    try
        //    {
        //        using (var dbContext = new ClassTrackerDbContext())
        //        {
        //            var entities = dbContext
        //                    .Organizations
        //                    .Where(filterFunc);
        //            var domains = entities.Select(x => MapEntityToDomain(x));
        //            return DataResult<List<Organization>>.CreateSuccessResult(domains.ToList());
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        return DataResult<List<Organization>>.CreateErrorResult(
        //            ErrorCode.ExceptionThrown, ex, null);
        //    }
        //}

        public DataResult <int?> CreateAsync(Organization domain)
        {
            try
            {
                var entity = _mapDomainToEntity(domain);
                using (var dbContext = new ClassTrackerDbContext())
                {
                    dbContext.Organizations.Add(entity);
                    dbContext.SaveChanges();
                    return(DataResult <int?> .CreateSuccessResult(entity.Id));
                }
            }
            catch (Exception ex)
            {
                return(DataResult <int?> .CreateErrorResult(
                           ErrorCode.ExceptionThrown, ex, null));
            }
        }
 public DataResult <List <Term> > GetAllAsync()
 {
     try
     {
         using (var dbContext = new ClassTrackerDbContext())
         {
             var entities = dbContext
                            .Terms;
             var domains = entities.Select(x => _mapEntityToDomain(x));
             return(DataResult <List <Term> > .CreateSuccessResult(domains.ToList()));
         }
     }
     catch (Exception ex)
     {
         return(DataResult <List <Term> > .CreateErrorResult(
                    ErrorCode.ExceptionThrown, ex, null));
     }
 }
 public Result UpdateAsync(Term domain)
 {
     try
     {
         var entity = _mapDomainToEntity(domain);
         using (var dbContext = new ClassTrackerDbContext())
         {
             dbContext.Terms.Attach(entity);
             dbContext.SaveChanges();
             return(Result.CreateSuccessResult());
         }
     }
     catch (Exception ex)
     {
         return(Result.CreateErrorResult(
                    ErrorCode.ExceptionThrown, ex, null));
     }
 }
 public Result DeleteAsync(Organization domain)
 {
     try
     {
         var entity = _mapDomainToEntity(domain);
         using (var dbContext = new ClassTrackerDbContext())
         {
             var entry = dbContext.Entry(entity);
             entry.State = EntityState.Deleted;
             dbContext.SaveChanges();
             return(Result.CreateSuccessResult());
         }
     }
     catch (Exception ex)
     {
         return(Result.CreateErrorResult(
                    ErrorCode.ExceptionThrown, ex, null));
     }
 }
 public DataResult <Organization> GetAsync(int id)
 {
     try
     {
         using (var dbContext = new ClassTrackerDbContext())
         {
             var entity = dbContext
                          .Organizations
                          .Where(x => x.Id == id)
                          .SingleOrDefault();
             var domain = _mapEntityToDomain(entity);
             return(DataResult <Organization> .CreateSuccessResult(domain));
         }
     }
     catch (Exception ex)
     {
         return(DataResult <Organization> .CreateErrorResult(
                    ErrorCode.ExceptionThrown, ex, null));
     }
 }