Constructor with argument :Missing return int value



I have class which contains many properties:



public class Report
{
public int reportId { get; set; }
public string sentDate { get; set; }
public string photoName { get; set; }
public string state { get; set; }
public string patientName { get; set; }
public string doctorName { get; set; }
public string sex { get; set; }
public int isPregnant { get; set; }
public float weight { get; set; }
public float height { get; set; }
public int age { get; set; }
public string information { get; set; }
public string response { get; set; }


then I implement one constructor with argmuents :



public Report(int id, string photoName, string sentDate, string state,string response)
{
this.reportId = id;
this.photoName = photoName;
this.sentDate = sentDate;
this.state = state;
this.response = response;
}


finally I implement method which calls this constructor :



public static List<Report> GetListReportByEmail(string email)
{
DataTable dt = SqlHelper.ExecuteDataset(
new SqlConnection(Tls.ConnStr),
"spReportGetByEmail",
email).Tables[0];
List<Report> tempItems = new List<Report>();
if (dt.Rows.Count != 0)
{

foreach (DataRow rw in dt.Rows)
{
tempItems.Add(
new Report(
int.Parse(rw["ReportId"].ToString()),
Tls.GetBasicUrl() + "/Zdnn000kjUpload/__zd__MedicalConsultation/"
+ rw["PhotoName"].ToString(),
DateTime.Parse(rw["SentDate"].ToString()).ToString("dd/M/yyyy"),
rw["State"].ToString(),
rw["Response"].ToString()));
}
return tempItems;
}
else
{
return null;
}
}


but when I check the return, in addition of the properties mentionned in the constructor I found all properties which its type is int or float with the value 0.


I need this methods for a web services. when I test this web serives I found properties mentionned in the constructor ,but also int and float which are not populated:



<Report>
<reportId>4</reportId>
<sentDate>21/6/2014</sentDate>
<photoName>
http://localhost:2055/Zdnn000kjUpload/__zd__MedicalConsultation/
</photoName>
<state/>
<isPregnant>0</isPregnant>
<weight>0</weight>
<height>0</height>
<age>0</age>

<response/>
</Report>


Knowing that the stored procedure is ok.


So can any one help me to transmit only variables mentionned in the constructor : I don't need age,height,weight,isPregnant to be transmitted


Thanks.


No comments:

Post a Comment