Esempio n. 1
0
        public bool edit(Todo todo)
        {
            using (dev101Entities entity = new dev101Entities())
            {
                try
                {
                    //int iid = Convert.ToInt32(todo.Id);

                    TaskEntity task = entity.TaskEntities.Single(pe => pe.id == todo.Id);
                    task.id       = todo.Id;
                    task.title    = todo.Title;
                    task.tags     = todo.Tags;
                    task.author   = todo.Author;
                    task.executor = todo.Executor;
                    task.datedue  = todo.DateDue;
                    task.datedone = todo.DateDone;

                    entity.SaveChanges();
                    return(true);
                }
                catch
                {
                    return(false);
                }
            };
        }
Esempio n. 2
0
        public bool create(Todo todo)
        {
            using (dev101Entities entity = new dev101Entities())
            {
                try
                {
                    TaskEntity task = new TaskEntity();
                    task.id       = todo.Id;
                    task.title    = todo.Title;
                    task.tags     = todo.Tags;
                    task.author   = todo.Author;
                    task.executor = todo.Executor;
                    task.datedue  = todo.DateDue;
                    task.datedone = todo.DateDone;

                    entity.TaskEntities.Add(task);
                    entity.SaveChanges();
                    return(true);
                }
                catch
                {
                    return(false);
                }
            };
        }
Esempio n. 3
0
 public List <Todo> findAll()
 {
     using (dev101Entities entity = new dev101Entities())
     {
         return(entity.TaskEntities.Select(pe => new Todo
         {
             Id = pe.id,
             Title = pe.title,
             Tags = pe.tags,
             Author = pe.author,
             Executor = pe.executor,
             DateDue = pe.datedue,
             DateDone = pe.datedone
         }).ToList());
     };
 }
Esempio n. 4
0
        public Todo find(string id)
        {
            using (dev101Entities entity = new dev101Entities())
            {
                int iid = Convert.ToInt32(id);

                return(entity.TaskEntities.Where(pe => pe.id == iid).Select(pe => new Todo
                {
                    Id = pe.id,
                    Title = pe.title,
                    Tags = pe.tags,
                    Author = pe.author,
                    Executor = pe.executor,
                    DateDue = pe.datedue,
                    DateDone = pe.datedone
                }).First());
            };
        }
Esempio n. 5
0
        public bool delete(Todo todo)
        {
            using (dev101Entities entity = new dev101Entities())
            {
                try
                {
                    TaskEntity task = entity.TaskEntities.Single(pe => pe.id == todo.Id);

                    entity.TaskEntities.Remove(task);

                    entity.SaveChanges();
                    return(true);
                }
                catch
                {
                    return(false);
                }
            };
        }