Hi guys im trying to implement a service that gets the atribute contaminatiotID that is on the two list i have created. im about to showing you up. What i want to do is to get the people with the same contaminationID on wcf.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
What I have tried:
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
[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));
}
}