Esempio n. 1
0
        public ActionResult TaskItem(int ID)
        {
            BaseReturn br = new BaseReturn();
            MobileTask mt = new MobileTask();

            var item = (from e in DbUtil.Db.Tasks
                        where e.Id == ID
                        select e).SingleOrDefault();

            br.type = 102;

            if (item != null)
            {
                br.count = 1;

                mt.populate(item);
                br.data = JSONHelper.JsonSerializer <MobileTask>(mt);
            }
            else
            {
                br.error = 1;
            }

            return(br);
        }
Esempio n. 2
0
        public ActionResult TaskCreate(string type, string data)   // Type 1001
        {
            BaseReturn br = new BaseReturn();

            br.type = 1001;

            MobileTask mt = JSONHelper.JsonDeserialize <MobileTask>(data);

            if (mt != null)
            {
                br.id = mt.addToDB();
            }
            else
            {
                br.error = 1;
                br.data  = "Task was not created.";
            }

            return(br);
        }
Esempio n. 3
0
        public ActionResult TaskUpdate(string type, string data)   // Type 1002
        {
            BaseReturn br = new BaseReturn();

            br.type = 1002;

            MobileTask mt = JSONHelper.JsonDeserialize <MobileTask>(data);

            var t = from e in DbUtil.Db.Tasks
                    where e.Id == mt.id
                    select e;

            if (t != null)
            {
                var task = t.Single();

                if (mt.updateDue > 0)
                {
                    task.Due = mt.due;
                }
                if (mt.statusID > 0)
                {
                    task.StatusId = mt.statusID;
                }
                if (mt.priority > 0)
                {
                    task.Priority = mt.priority;
                }
                if (mt.notes.Length > 0)
                {
                    task.Notes = mt.notes;
                }
                if (mt.description.Length > 0)
                {
                    task.Description = mt.description;
                }
                if (mt.ownerID > 0)
                {
                    task.OwnerId = mt.ownerID;
                }
                if (mt.boxID > 0)
                {
                    task.ListId = mt.boxID;
                }
                if (mt.aboutID > 0)
                {
                    task.WhoId = mt.aboutID;
                }
                if (mt.delegatedID > 0)
                {
                    task.CoOwnerId = mt.delegatedID;
                }
                if (mt.notes.Length > 0)
                {
                    task.Notes = mt.notes;
                }

                DbUtil.Db.SubmitChanges();

                br.data = "Task updated.";
            }
            else
            {
                br.error = 1;
                br.data  = "Task not found.";
            }

            return(br);
        }