Пример #1
0
        public UserService(ModelManagementContext context = null) : base(context)
        {
            var appContext = context ?? new ModelManagementContext();

            _appRepository = new AppRepository(appContext);
            _mapper        = new ObjectMapper();
        }
Пример #2
0
 public UnitOfWork()
 {
     if (this.dbContext == null)
     {
         this.dbContext = new ModelManagementContext();
     }
 }
        public CategoryService(ModelManagementContext context = null) : base(context)
        {
            //_context = context ?? new ModelManagementContext();
            //_categotyRepo = new EntityRepository<Category>(context);
            var appContext = context ?? new ModelManagementContext();

            _appRepository = new AppRepository(appContext);
        }
Пример #4
0
        public ContentService(ModelManagementContext context = null) : base(context)
        {
            var appContext = context ?? new ModelManagementContext();

            _appRepository = new AppRepository(appContext);
            //_uplodableRepository = new EntityRepository<Uploadable>(_context);
            _mapper = new ObjectMapper();
        }
Пример #5
0
        public CommonDataService(ModelManagementContext context = null) : base(context)
        {
            var appContext = context ?? new ModelManagementContext();

            _appRepository = new AppRepository(appContext);

            _geoTypeRepository  = new EntityRepository <GeoType>(_context);
            _geoRepository      = new EntityRepository <Geo>(_context);
            _geoAssocRepository = new EntityRepository <GeoAssoc>(_context);
            //_appRepository = new AppRepository(_context);
            //Context = context;
        }
Пример #6
0
 private void Dispose(bool disposing)
 {
     if (!disposing)
     {
         return;
     }
     if (dbContext == null)
     {
         return;
     }
     dbContext.Dispose();
     dbContext = null;
 }
 public virtual TEntity Create(TEntity TObject)
 {
     using (var context = new ModelManagementContext())
     {
         using (var dbTransaction = context.Database.BeginTransaction())
         {
             try
             {
                 TEntity newE = context.Set <TEntity>().Add(TObject);
                 context.SaveChanges();
                 dbTransaction.Commit();
                 return(newE);
             }
             catch (Exception exception)
             {
                 dbTransaction.Rollback();
                 throw exception;
             }
         }
     }
     //using (var dbTransaction = uow.DbContext.Database.BeginTransaction())
     //{
     //    try
     //    {
     //        TEntity newEntity = DbSet.Add(TObject);
     //        if (!shareContext)
     //        {
     //            if (uow.SaveChanges() > 0)
     //            {
     //                dbTransaction.Commit();
     //                return newEntity;
     //            }
     //        }
     //    }
     //    catch (Exception exception)
     //    {
     //        dbTransaction.Rollback();
     //        uow = new UnitOfWork();
     //        throw exception;
     //    }
     //}
     //TEntity newEntity = DbSet.Add(TObject);
     //if (!shareContext)
     //{
     //    if (uow.SaveChanges() > 0)
     //    {
     //        return newEntity;
     //    }
     //}
 }
        //public virtual bool Update(TEntity TObject)
        //{
        //    var entry = uow.DbContext.Entry(TObject);
        //    DbSet.Attach(TObject);
        //    entry.State = EntityState.Modified;
        //    if (!shareContext)
        //        return uow.SaveChanges() >= 0;
        //    return false;
        //}
        public virtual TEntity Update(TEntity TObject)
        {
            TObject.LastUpdatedStamp = DateTime.Now;
            ModelManagementContext context = uow.DbContext;
            var     entry     = uow.DbContext.Entry(TObject);
            TEntity newEntity = DbSet.Attach(TObject);

            entry.State = EntityState.Modified;
            if (!shareContext)
            {
                if (uow.SaveChanges() >= 0)
                {
                    context.Entry(TObject).State = EntityState.Detached;
                    return(newEntity);
                }
            }
            return(null);
        }
Пример #9
0
 public ModelManagementQuery(ModelManagementContext context)
 {
     this._context = context;
 }
Пример #10
0
 public ModelManagementQueryServices()
 {
     _context = new ModelManagementContext();
     _query   = new ModelManagementQuery(this._context);
 }
Пример #11
0
 public void TestMethod1()
 {
     _context = new ModelManagementContext();
     _context.Database.Delete();
     _context.Database.CreateIfNotExists();
 }
Пример #12
0
        public ContactService(ModelManagementContext context = null) : base(context)
        {
            var appContext = context ?? new ModelManagementContext();

            _appRepository = new AppRepository(appContext);
        }
 public EntityRepository()
 {
     this._context = new ModelManagementContext();
 }
 public TransactionScope()
 {
     Context        = new ModelManagementContext();
     _dbTransaction = Context.Database.BeginTransaction();
 }
Пример #15
0
 public AppRepository(ModelManagementContext context = null)
 {
     Context = context ?? new ModelManagementContext();
 }
Пример #16
0
 public UnitOfWork(ModelManagementContext dbContext)
 {
     this.dbContext = dbContext;
 }
 public EntityRepository(ModelManagementContext context)
 {
     this._context = context;
 }
Пример #18
0
 public Class1(ModelManagementContext context)
 {
     Context = context;
 }
Пример #19
0
 public ModelManagementApiService()
 {
     _context = new ModelManagementContext();
 }
 public CommonDataQuery(ModelManagementContext context)
 {
     _context = context;
 }