So folks, I need to consume a Web Service for an airline company. But, there are still two tasks that I need to add to the .asmx server and I'm having second thoughts. An operation is:
1) Consult Flight (query information): date of flight, origin, destination. This service should return a list with: date and time of flight, flight number, origin and destination, aircraft and number of seats available (calculated from the quantity registered, decreasing tickets sold), ticket price;
In the part that is asked as a parameter to query the flights (date, origin and destination), I do not know how to do this operation correctly. I already made a method of Query passing DATE and INTEGER value, but using STRING I have not yet used it. There is also, doubt as to how to calculate the amount of seats available. Here is an attempt:
[WebMethod]
public List<Voo> TodosVoosDataOrigemDestino(DateTime data, String origem, String destino)
{
var voos = DbFactory.Instance.VooRepository.FindAll().ToList();
voos = voos.Where(w => w.DataVoo.Date == data.Date && w.OrigemVoo.ToLower() == destino.ToLower() && w.OrigemVoo.ToLower() == destino.ToLower()).ToList();
return voos;
}
Now the second operation:
2) Buy Ticket (inquiry information for purchase): flight number, number of tickets. On this server, an internal validation should be done if there are the number of tickets available, otherwise it should return an exception stating the impossibility of purchasing.
That, I did not even try to do. If you can at least give a "light", I would be very grateful.
This is a diagram for this activity (if needed):
Some extra information (I'm not sure if these will be needed): I'm going to consume this Web Service using ASP.NET MVC. I created the Database with NHibernate. If you are missing more information, let me know. I'm still new, both in the forum and in the area of Web Service.