Beispiel #1
0
 public SchedulePluginsInfo FindOne(int id)
 {
     using (var context = new ScheduleContext())
     {
         return(context.Plugins.FirstOrDefault(c => c.Id == id));
     }
 }
Beispiel #2
0
 public ScheduleJobsInfo FindOne(Guid id)
 {
     using (var context = new ScheduleContext())
     {
         return(context.ScheduleJobs.FirstOrDefault(c => c.Id == id));
     }
 }
Beispiel #3
0
        public IQueryable <SchedulePluginsInfo> Find(Expression <Func <SchedulePluginsInfo, bool> > query)
        {
            var context = new ScheduleContext();

            if (query != null)
            {
                return(context.Plugins.Where(query).OrderByDescending(c => c.Id));
            }
            return(context.Plugins.OrderByDescending(c => c.Id).AsQueryable());
        }
Beispiel #4
0
        public IQueryable <ScheduleJobsInfo> Find(Expression <Func <ScheduleJobsInfo, bool> > query)
        {
            var context = new ScheduleContext();

            if (query != null)
            {
                return(context.Set <ScheduleJobsInfo>().Where(query));
            }
            return(context.ScheduleJobs.AsQueryable <ScheduleJobsInfo>());
        }
Beispiel #5
0
 public bool Remove(int id)
 {
     using (var context = new ScheduleContext())
     {
         var entity = context.Plugins.FirstOrDefault(c => c.Id == id);
         if (entity != null)
         {
             context.Plugins.Attach(entity);
             context.Entry <SchedulePluginsInfo>(entity).State = System.Data.Entity.EntityState.Deleted;
             context.SaveChanges();
         }
     }
     return(true);
 }
Beispiel #6
0
 public bool Save(SchedulePluginsInfo entity)
 {
     using (var context = new ScheduleContext())
     {
         if (entity.Id == 0)
         {
             context.Plugins.Add(entity);
             context.Entry <SchedulePluginsInfo>(entity).State = System.Data.Entity.EntityState.Added;
         }
         else
         {
             var info = context.Plugins.FirstOrDefault(c => c.Id == entity.Id);
             if (entity != null)
             {
                 context.Entry <SchedulePluginsInfo>(entity).State = System.Data.Entity.EntityState.Modified;
             }
         }
         context.SaveChanges();
     }
     return(true);
 }
Beispiel #7
0
        public bool Save(ScheduleJobsInfo entity)
        {
            ScheduleJobsInfo info = FindOne(entity.Id);

            if (info == null)
            {
                using (var context = new ScheduleContext())
                {
                    context.ScheduleJobs.Add(entity);
                    context.Entry <ScheduleJobsInfo>(entity).State = EntityState.Added;
                    context.SaveChanges();
                }
                return(true);
            }
            using (var context = new ScheduleContext())
            {
                //context.ScheduleJobs.AddObject(entity);
                context.Entry <ScheduleJobsInfo>(entity).State = EntityState.Modified;
                int r = context.SaveChanges();
            }
            return(true);
        }