Пример #1
0
        public static int CreateTask(Task tsk)
        {
            int id = -1;
            SanityDataModelDataContext context = new SanityDataModelDataContext(ConnectionString);
            try
            {
                context.Tasks.InsertOnSubmit(tsk);
                context.SubmitChanges();
                id = tsk.ID;
            }
            catch (Exception ex)
            {

            }
            return id;
        }
Пример #2
0
        public static int CreateProject(project prj)
        {
            int id = -1;
            SanityDataModelDataContext context = new SanityDataModelDataContext(ConnectionString);
            try
            {
                context.projects.InsertOnSubmit(prj);
                context.SubmitChanges();
                id = prj.ID;
            }
            catch (Exception ex)
            {

            }
            return id;
        }
Пример #3
0
        public static bool DeleteTask(int id)
        {
            bool sucessful = false;
            SanityDataModelDataContext context = new SanityDataModelDataContext(ConnectionString);
            var qry = from T in context.Tasks
                      where T.ID == id
                      select T;

            Task t = qry.FirstOrDefault();
            if (t != null)
            {

                context.Tasks.DeleteOnSubmit(t);
                context.SubmitChanges();
                sucessful = true;
            }

            return sucessful;
        }
Пример #4
0
        public static bool DeleteProject(int id)
        {
            bool sucessful = false;
            SanityDataModelDataContext context = new SanityDataModelDataContext(ConnectionString);
            var qry = from P in context.projects
                      where P.ID == id
                      select P;

            project p = qry.FirstOrDefault();
            if (p != null)
            {

                context.projects.DeleteOnSubmit(p);
                context.SubmitChanges();
                sucessful = true;
            }

            return sucessful;
        }
Пример #5
0
        public static project GetProjectByID(int id)
        {
            SanityDataModelDataContext context = new SanityDataModelDataContext(ConnectionString);
            var qry = from P in context.projects
                      where P.ID == id
                      select P;

            return qry.FirstOrDefault();
        }
Пример #6
0
        public static bool UpdateTask(Task tsk)
        {
            bool sucessful = false;
            SanityDataModelDataContext context = new SanityDataModelDataContext(ConnectionString);

            var qry = from T in context.Tasks
                      where T.ID == tsk.ID
                      select T;

               Task t = qry.FirstOrDefault();
            if (t!= null)
            {
                t.Completed = tsk.Completed;
                t.Created = tsk.Created;
                t.Description = tsk.Description;
                t.Due = tsk.Due;
                t.IdeaID = tsk.IdeaID;
                t.Notes = tsk.Notes;
                t.ProjectID = tsk.ProjectID;

                context.SubmitChanges();
                sucessful = true;
            }

            return sucessful;
        }
Пример #7
0
        public static bool UpdateProject(project prj)
        {
            bool sucessful = false;
            SanityDataModelDataContext context = new SanityDataModelDataContext(ConnectionString);

            var qry = from P in context.projects
                      where P.ID == prj.ID
                      select P;

            project p = qry.FirstOrDefault();
            if(p!=null)
            {
                p.Created = prj.Created;
                p.Description = prj.Description;
                p.JobNumber = prj.JobNumber;
                p.Notes = prj.Notes;

                context.SubmitChanges();
                sucessful = true;
            }

            return sucessful;
        }
Пример #8
0
        public static IEnumerable<Task> GetTasksByProjectID(int pid)
        {
            SanityDataModelDataContext context = new SanityDataModelDataContext(ConnectionString);
            var qry = from T in context.Tasks
                      where T.ProjectID == pid
                      select T;

            return qry;
        }
Пример #9
0
        public static IEnumerable<Task> GetTasks()
        {
            SanityDataModelDataContext context = new SanityDataModelDataContext(ConnectionString);
            var qry = from T in context.Tasks
                      select T;

            return qry;
        }
Пример #10
0
        public static Task GetTaskByID(int id)
        {
            SanityDataModelDataContext context = new SanityDataModelDataContext(ConnectionString);
            var qry = from T in context.Tasks
                      where T.ID == id
                      select T;

            return qry.FirstOrDefault();
        }
Пример #11
0
        public static IEnumerable<project> GetProjects()
        {
            SanityDataModelDataContext context = new SanityDataModelDataContext(ConnectionString);
            var qry = from P in context.projects
                select P;

            return qry;
        }