i'm learning how to work with wcf(soap), doing a webservice im trying to implement a service that gets the atribute contaminatiotID that is in the two list's i have created. What i want to do is to get the people with the same contaminationID. For example Infeted is the person with covid and isolated are the people that had contact with the infected. What im trying to do is a service that retrive the two list of people with the same contamination ID when i invoke in this case contaminationID = 1.
This is what i have tried on my wcf aplication project on Visual Studio:
This is what i implemented so far
Paste Models:
infected.cs
namespace DgsSoapWebService.Models
{
[DataContract]
public class Infected
{
[DataMember]
public string Nome { get; set; }
[DataMember]
public int Datanasc { get; set; }
[DataMember]
public string Cidade { get; set; }
[DataMember]
public int Nrutente { get; set; }
[DataMember]
public bool Covid { get; set; }
[DataMember]
public int ContaminationID { get; set; }
}
}
Isolated.cs
public class Isolated : Infected
{
[DataMember]
public bool Internado { get; set; }
[DataMember]
public string LocalInternamento { get; set; }
[DataMember]
public string DataInternamento { get; set; }
}
Paste Services: IInfecteds.cs
Copy Code
[ServiceContract]
public interface IInfecteds
{
[OperationContract]
List<Infected> GetNome(string nomefiltro ="");
[OperationContract]
Isolated GetAllContaminationID(int contaminationID);
}
Infecteds.svc
public class Infecteds : IInfecteds
{
List<Infected> infecteds;
List<Isolated> isolateds;
public Infecteds()
{
infecteds = new List<Infected>
{
new Infected { Nome = "zeze", Datanasc= 2000-23-12, Cidade="Lisboa", Nrutente= 12344512, Covid = true, ContaminationID = 1}
};
isolateds = new List<Isolated>
{
new Isolated { Nome = "tone", Datanasc= 2000-23-12, Cidade="Cascais", Nrutente= 23244512, Covid = true, ContaminationID = 1}
};
}
public List<Infected> GetNome(string nomefiltro = "")
{
return infecteds.Where(p => p.Nome.Contains(nomefiltro)).ToList();
}
public Isolated GetAllContaminationID(int contaminationID)
{
return isolateds.FirstOrDefault(p => p.ContaminationID.Equals(contaminationID));
}
}