예제 #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
		private void detach_Tasks(Task entity)
		{
			this.SendPropertyChanging();
			entity.project = null;
		}
예제 #3
0
		private void attach_Tasks(Task entity)
		{
			this.SendPropertyChanging();
			entity.project = this;
		}
예제 #4
0
 partial void DeleteTask(Task instance);
예제 #5
0
 partial void UpdateTask(Task instance);
예제 #6
0
 partial void InsertTask(Task instance);
예제 #7
0
 // PUT api/values/5
 public HttpResponseMessage Put(int id, [FromBody]serTask tsk)
 {
     bool sucessful = false;
     DataManager.ConnectionString = connectionString;
     if (tsk != null)
     {
        Task t = new Task()
         {
             ID=tsk.ID,
             Created = tsk.Created == DateTime.MinValue ? (DateTime?)null : tsk.Created,
             Due = tsk.Due == DateTime.MinValue ? (DateTime?)null : tsk.Due,
             Completed = tsk.Completed == DateTime.MinValue ? (DateTime?)null : tsk.Completed,
             Description = tsk.Description,
             IdeaID = tsk.IdeaID,
             Notes = tsk.Notes,
             ProjectID = tsk.ProjectID
         };
        sucessful = DataManager.UpdateTask(t);
     }
     if (sucessful)
     {
         return Request.CreateResponse(HttpStatusCode.OK);
     }
     else
     {
         return Request.CreateResponse(HttpStatusCode.InternalServerError);
     }
 }
예제 #8
0
        // POST api/values
        public HttpResponseMessage Post([FromBody]serTask tsk)
        {
            DataManager.ConnectionString = connectionString;
            int id = -1;
            if (tsk != null)
            {
               Task t = new Task()
                {
                   Created = DateTime.Now,
                   Due = tsk.Due == DateTime.MinValue ? (DateTime?)null : tsk.Due,
                   Completed = tsk.Completed == DateTime.MinValue ? (DateTime?)null : tsk.Completed,
                   Description = tsk.Description,
                   IdeaID = tsk.IdeaID,
                   Notes = tsk.Notes,
                   ProjectID = tsk.ProjectID
                };

                id = DataManager.CreateTask(t);
            }

            if (id > -1)
            {
                return Request.CreateResponse(HttpStatusCode.OK);
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.InternalServerError);
            }
        }
예제 #9
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;
        }