Exemple #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);
                }
            };
        }
Exemple #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);
                }
            };
        }
Exemple #3
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);
                }
            };
        }