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; }
private void detach_Tasks(Task entity) { this.SendPropertyChanging(); entity.project = null; }
private void attach_Tasks(Task entity) { this.SendPropertyChanging(); entity.project = this; }
partial void DeleteTask(Task instance);
partial void UpdateTask(Task instance);
partial void InsertTask(Task instance);
// 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); } }
// 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); } }
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; }