private WebAPI.Models.Project DataRowToWebApiModel(DataRow dr) { WebAPI.Models.Project project = new WebAPI.Models.Project(); try { if (dr["pid"] != System.DBNull.Value) { project.PID = (String)dr["pid"]; } if (dr["ProjIcon"] != System.DBNull.Value) { project.Icon = (String)dr["ProjIcon"]; } if (dr["ProjCode"] != System.DBNull.Value) { project.Code = (String)dr["ProjCode"]; } if (dr["ProjName"] != System.DBNull.Value) { project.Name = (String)dr["ProjName"]; } if (dr["ProjDesc"] != System.DBNull.Value) { project.Description = (String)dr["ProjDesc"]; } if (dr["ProjEstStartDate"] != System.DBNull.Value) { project.EstimatedStartDate = (String)dr["ProjEstStartDate"]; } if (dr["ProjEstEndDate"] != System.DBNull.Value) { project.EstimatedEndDate = (String)dr["ProjEstEndDate"]; } if (dr["ProjActStartDate"] != System.DBNull.Value) { project.ActualStartDate = (String)dr["ProjActStartDate"]; } if (dr["ProjActEndDate"] != System.DBNull.Value) { project.ActualEndDate = (String)dr["ProjActEndDate"]; } if (dr["ProjFolder"] != System.DBNull.Value) { project.Folder = (String)dr["ProjFolder"]; } if (dr["ProjCaption"] != System.DBNull.Value) { project.Caption = (String)dr["ProjCaption"]; } if (dr["ProjURL"] != System.DBNull.Value) { project.URL = (String)dr["ProjURL"]; } if (dr["ProjOrg"] != System.DBNull.Value) { project.Organization = (String)dr["ProjOrg"]; } return project; } catch (Exception ex) { return null; } }
private WebAPI.Models.Project DALObjectToWebApiModel(ProjectMgmt.Project data) { WebAPI.Models.Project project = new WebAPI.Models.Project(); try { project.PID = data.PID.ToString(); project.Icon = data.Icon; project.Code =data.Code; project.Name = data.Name; project.Description = data.Description; project.EstimatedStartDate = (data.EstimatedStartDate.HasValue) ? ((DateTime)data.EstimatedStartDate).ToString("yyyy-MM-dd HH:mm:ss") : ""; project.EstimatedEndDate = (data.EstimatedEndDate.HasValue) ? ((DateTime)data.EstimatedEndDate).ToString("yyyy-MM-dd HH:mm:ss") : ""; project.ActualStartDate = (data.ActualStartDate.HasValue) ? ((DateTime)data.ActualStartDate).ToString("yyyy-MM-dd HH:mm:ss") : ""; project.ActualEndDate = (data.ActualEndDate.HasValue) ? ((DateTime)data.ActualEndDate).ToString("yyyy-MM-dd HH:mm:ss") : ""; project.Folder = data.Folder; project.Caption = data.Caption; project.URL = data.URL; project.Organization = data.Organization; return project; } catch (Exception ex) { return null; } }