public XElement UpdateReminder(int activity, string reminder) { XElement x = new XElement("activities"); DBHelper db = new DBHelper(dbcstring); db.UpdateReminder(activity, DateTime.Parse(reminder)); AActivity aactivity = db.GetActivity(activity); if (aactivity != null) { XElement xproject = new XElement("activity"); xproject.Add(new XElement("id", aactivity.ID.ToString())); xproject.Add(new XElement("title", aactivity.Title.Trim())); xproject.Add(new XElement("date", aactivity.Date)); xproject.Add(new XElement("created", aactivity.Created)); xproject.Add(new XElement("reminder", aactivity.Reminder)); xproject.Add(new XElement("priority", aactivity.Priority)); xproject.Add(new XElement("completed", aactivity.Completed)); x.Add(xproject); } return(x); }
public XElement RegisterActivity(int project, string title, int parentActivity, int priority, string due, string reminder, int completed) { XElement x = new XElement("activities"); DBHelper db = new DBHelper(dbcstring); DateTime ddue = DateTime.Parse(due), dreminder = DateTime.Parse(reminder); bool bcompleted = (completed > 0); int registeredid = db.RegisterActivity(project, title, ddue, parentActivity, Convert.ToByte(priority), dreminder, bcompleted); AActivity activity = db.GetActivity(registeredid); if (activity != null) { XElement xproject = new XElement("activity"); xproject.Add(new XElement("id", activity.ID.ToString())); xproject.Add(new XElement("title", activity.Title.Trim())); xproject.Add(new XElement("date", activity.Date)); xproject.Add(new XElement("created", activity.Created)); xproject.Add(new XElement("reminder", activity.Reminder)); xproject.Add(new XElement("priority", activity.Priority)); xproject.Add(new XElement("completed", activity.Completed)); x.Add(xproject); } return(x); }
/// <summary> /// Obtiene una actividad según su identificador. /// </summary> /// <param name="id">Identificador de la actividad.</param> /// <returns>Instancia de la actividad solicitada.</returns> public AActivity GetActivity(int id) { conn.Open(); SqlCommand command = new SqlCommand("select * from [dbo].[fGetActivity] (" + id + ")", conn); SqlDataAdapter adapter = new SqlDataAdapter(command); DataTable table = new DataTable("activity"); adapter.Fill(table); conn.Close(); if (table.Rows.Count > 0) { int rowid = (int)table.Rows[0]["ID"]; string rowtitle = table.Rows[0]["Title"].ToString(); DateTime due = (DateTime)table.Rows[0]["DueDate"]; DateTime created = (DateTime)table.Rows[0]["Created"]; DateTime reminder = (DateTime)table.Rows[0]["Reminder"]; short priority = (short)table.Rows[0]["Priority"]; bool completed = (bool)table.Rows[0]["Completed"]; int parentActivity = (int)table.Rows[0]["ParentActivity"]; AActivity result = new AActivity(rowid, rowtitle, due, reminder, byte.Parse(priority.ToString()), completed) { Created = created, ProjectID = int.Parse(table.Rows[0]["Project"].ToString()), Parent = parentActivity }; return(result); } else { return(null); } }
public async Task <ActionResult <AActivity> > PostAActivity(AActivity aActivity) { _context.AActivity.Add(aActivity); await _context.SaveChangesAsync(); return(CreatedAtAction("GetAActivity", new { id = aActivity.Id }, aActivity)); }
public async Task <IActionResult> PutAActivity(int id, AActivity aActivity) { if (id != aActivity.Id) { return(BadRequest()); } _context.Entry(aActivity).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AActivityExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public SyncCom(AActivity activity) { this.activity = activity; }