public List<ProjectModel> GetProject()
        {
            DatabaseProviderFactory factory = new DatabaseProviderFactory();
            Database db = factory.Create("JIRA");
            List<ProjectModel> modelList = new List<ProjectModel>();
            using (DbCommand cmd = db.GetStoredProcCommand("[dbo].[GetProject]"))
            {
                cmd.CommandTimeout = dbTimeout;
                db.AddOutParameter(cmd, "@Result", DbType.Int32, Int32.MaxValue);
                DataSet ds = db.ExecuteDataSet(cmd);

                // DB returns 1 if there is no error.
                int result = (int)db.GetParameterValue(cmd, "@Result");
                if (result == 1)
                {
                    DataTable dt = ds.Tables[0];
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        ProjectModel model = new ProjectModel();
                        model.Id = (int)dt.Rows[i]["Id"];
                        model.Subject = dt.Rows[i]["Subject"].ToString();
                        model.Status = (int)dt.Rows[i]["Status"];
                        model.ReleasedVersion = dt.Rows[i]["ReleasedVersion"].ToString();
                        model.Description = dt.Rows[i]["Description"].ToString();
                        model.SourceRespository = dt.Rows[i]["SourceRespository"].ToString();
                        model.UpdatedTimeStamp = (DateTime)dt.Rows[i]["UpdatedTimeStamp"];
                        modelList.Add(model);
                    }
                }
            }

            return modelList;
        }
        public int UpsertProject(ProjectModel model)
        {
            DatabaseProviderFactory factory = new DatabaseProviderFactory();
            Database db = factory.Create("JIRA");
            int result = 0;
            using (DbCommand cmd = db.GetStoredProcCommand("[dbo].[UpsertProject]"))
            {
                cmd.CommandTimeout = dbTimeout;
                db.AddInParameter(cmd, "@Id", DbType.Int32, model.Id);
                db.AddInParameter(cmd, "@Subject", DbType.String, model.Subject);
                db.AddInParameter(cmd, "@Description", DbType.String, model.Description);
                db.AddInParameter(cmd, "@Status", DbType.Int32, model.Status);
                db.AddInParameter(cmd, "@SourceRespository", DbType.String, model.SourceRespository);
                db.AddInParameter(cmd, "@ReleasedVersion", DbType.String, model.ReleasedVersion);
                db.AddInParameter(cmd, "@UpdatedTimeStamp", DbType.DateTime2, model.UpdatedTimeStamp);
                db.AddOutParameter(cmd, "@Result", DbType.Int32, Int32.MaxValue);
                DataSet ds = db.ExecuteDataSet(cmd);

                // DB returns 1 if there is no error.
                result = (int)db.GetParameterValue(cmd, "@Result");
            }
            return result;
        }
 public int UpsertProject(ProjectVM viewModel)
 {
     ProjectModel model = new ProjectModel();
     model.Id = int.Parse(viewModel.Id);
     model.Subject = viewModel.Name;
     model.ReleasedVersion = viewModel.ReleasedVersion;
     model.SourceRespository = viewModel.SourceRespository;
     model.Description = viewModel.Description;
     model.Status = int.Parse(viewModel.StatusDropDownList);
     model.UpdatedTimeStamp = DateTime.Now;
     return _projectDataAccess.UpsertProject(model);
 }