예제 #1
0
        public int DeleteTaskById(int id)
        {
            TODOEntities tdDb = new TODOEntities();
            Tasks        tsk  = new Tasks();

            tsk.id = id;

            tdDb.Entry(tsk).State = System.Data.Entity.EntityState.Deleted;

            int retVal = tdDb.SaveChanges();

            return(retVal);
        }
예제 #2
0
        public int AddTask(string title, string description)
        {
            TODOEntities tdDb = new TODOEntities();
            Tasks        tsk  = new Tasks();

            tsk.title       = title;
            tsk.description = description;

            tdDb.Tasks.Add(tsk);

            int retVal = tdDb.SaveChanges();

            return(retVal);
        }
예제 #3
0
        public int UpdateTask(int id, string title, string description)
        {
            TODOEntities tdDb = new TODOEntities();
            Tasks        tsk  = new Tasks();

            tsk.id          = id;
            tsk.title       = title;
            tsk.description = description;

            tdDb.Entry(tsk).State = System.Data.Entity.EntityState.Modified;

            int retVal = tdDb.SaveChanges();

            return(retVal);
        }
예제 #4
0
        public Tasks GetTaskById(int id)
        {
            TODOEntities tdDb       = new TODOEntities();
            var          taskResult = from tk in tdDb.Tasks where tk.id == id select tk;
            Tasks        tsk        = new Tasks();

            foreach (var task in taskResult)
            {
                tsk.id          = task.id;
                tsk.title       = task.title;
                tsk.description = task.description;
            }

            return(tsk);
        }
예제 #5
0
        public List <Tasks> GetTasks()
        {
            List <Tasks> taskList   = new List <Tasks>();
            TODOEntities tdDb       = new TODOEntities();
            var          taskResult = from tk in tdDb.Tasks select tk;

            foreach (var task in taskResult)
            {
                Tasks tsk = new Tasks();
                tsk.id          = task.id;
                tsk.title       = task.title;
                tsk.description = task.description;

                taskList.Add(tsk);
            }

            return(taskList);
        }