Ejemplo n.º 1
0
 public void DeleteAll()
 {
     using (var ctx = new TasksDbContext())
     {
         ctx.Database.ExecuteSqlCommand("TRUNCATE TABLE [TaskEntities]");
     }
 }
Ejemplo n.º 2
0
 public IEnumerable <TaskEntity> GetAll()
 {
     using (var ctx = new TasksDbContext())
     {
         return(ctx.Tasks.AsEnumerable());
     }
 }
Ejemplo n.º 3
0
 public void DeleteAllByType(string type)
 {
     using (var ctx = new TasksDbContext())
     {
         ctx.Tasks.RemoveRange(ctx.Tasks);
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 4
0
        public void Add(string tasktype, string details, string worker)
        {
            using (var ctx = new TasksDbContext())
            {
                var t = new TaskEntity()
                {
                    ExecutionDT = DateTime.UtcNow,
                    TaskType    = tasktype,
                    Worker      = worker,
                    Details     = details
                };

                ctx.Tasks.Add(t);

                ctx.SaveChanges();
            }
        }