using System; using Yavsc; using Npgsql; using Yavsc.Model; namespace Yavsc { /// /// ITCP npgsql provider. /// public class ITCPNpgsqlProvider : NpgsqlContentProvider { /* TODO int NewProject(string name, string desc, string ownedId); void AddDevRessource (int prjId, string userName); int NewTask(int projectId, string name, string desc); void SetProjectName(int projectId, string name); void SetProjectDesc(int projectId, string desc); void SetTaskName(int taskId, string name); void SetStartDate(int taskId, DateTime d); void SetEndDate(int taskId, DateTime d); void SetTaskDesc(int taskId, string desc); void NewRelease(int projectId, string Version); */ /// /// Initializes a new instance of the class. /// public ITCPNpgsqlProvider () { } /// /// Gets the project info. /// /// The project info. /// Projectid. public ProjectInfo GetProjectInfo(int projectid) { throw new NotImplementedException (); } /// /// Searchs the project. /// /// The project. /// Pi. public ProjectInfo[] SearchProject(ProjectInfo pi) { throw new NotImplementedException (); } /// /// News the task. /// /// The task. /// Project identifier. /// Name. /// Desc. public int NewTask (int projectId, string name, string desc) { throw new System.NotImplementedException (); } /// /// Sets the name of the task. /// /// Task identifier. /// Name. public void SetTaskName (int taskId, string name) { throw new System.NotImplementedException (); } /// /// Sets the start date. /// /// Task identifier. /// D. public void SetStartDate (int taskId, DateTime d) { throw new System.NotImplementedException (); } /// /// Sets the end date. /// /// Task identifier. /// D. public void SetEndDate (int taskId, DateTime d) { throw new System.NotImplementedException (); } /// /// Removes the project. /// /// Prj identifier. public void RemoveProject (int prjId) { using (var cnx = CreateConnection()) { cnx.Open (); using (NpgsqlCommand cmd = cnx.CreateCommand()) { cmd.CommandText = "delete from projets where id = @id"; cmd.Parameters.AddWithValue ("@id", prjId); cmd.ExecuteNonQuery(); } cnx.Close (); } } /// /// News the project. /// /// The project. /// Name. /// Desc. /// Owner identifier. public int NewProject (string name, string desc, string ownerId) { int id = 0; using (var cnx = CreateConnection()) { cnx.Open (); using (NpgsqlCommand cmd = cnx.CreateCommand()) { cmd.CommandText = "insert into projets (name,managerid,ApplicatonName,prdesc) values (@name,@mid,@appname,@pdesc)"; cmd.Parameters.AddWithValue ("@name", name); cmd.Parameters.AddWithValue ("@mid", ownerId); cmd.Parameters.AddWithValue ("@appname", ApplicationName); cmd.Parameters.AddWithValue ("@desc", desc); id = (int)cmd.ExecuteScalar (); } cnx.Close (); } return id; } } }