add the Plattform service
This commit is contained in:
parent
c94aff0a6b
commit
41b6c58cd0
|
@ -4,6 +4,8 @@ using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.ServiceModel;
|
using System.ServiceModel;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Plattform.DB;
|
||||||
|
using Plattform.Models;
|
||||||
|
|
||||||
namespace Plattform
|
namespace Plattform
|
||||||
{
|
{
|
||||||
|
@ -12,6 +14,12 @@ namespace Plattform
|
||||||
public interface IPlattformService
|
public interface IPlattformService
|
||||||
{
|
{
|
||||||
[OperationContract]
|
[OperationContract]
|
||||||
void DoWork();
|
List<SpecialOffer> GetSpecialOffers();
|
||||||
|
[OperationContract]
|
||||||
|
bool ReserveSpecialOffer(SpecialOffer offer);
|
||||||
|
[OperationContract]
|
||||||
|
bool BookSpecialOffer(SpecialOffer offer);
|
||||||
|
[OperationContract]
|
||||||
|
bool CancelSpecialOffer(SpecialOffer offer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,9 @@ using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.ServiceModel;
|
using System.ServiceModel;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Plattform.DB;
|
||||||
|
using Plattform.Models;
|
||||||
|
using Plattform.AirlineService;
|
||||||
|
|
||||||
namespace Plattform
|
namespace Plattform
|
||||||
{
|
{
|
||||||
|
@ -14,8 +17,65 @@ namespace Plattform
|
||||||
// Explorer and start debugging.
|
// Explorer and start debugging.
|
||||||
public class PlattformService : IPlattformService
|
public class PlattformService : IPlattformService
|
||||||
{
|
{
|
||||||
public void DoWork()
|
SpecialOfferDB db = new SpecialOfferDB();
|
||||||
|
AirlineServiceClient client = new AirlineServiceClient();
|
||||||
|
public List<SpecialOffer> GetSpecialOffers()
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return db.GetAllSpecialOffers();
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Trace.WriteLine(e);
|
||||||
|
return new List<SpecialOffer>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool ReserveSpecialOffer(SpecialOffer offer)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
client.BookFlight(offer.FlightTo, offer.Room.RoomType.Capacity);
|
||||||
|
client.BookFlight(offer.FlightFrom, offer.Room.RoomType.Capacity);
|
||||||
|
offer.Reserverd = true;
|
||||||
|
db.UpdateSpecialOffer(offer);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Trace.WriteLine(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool BookSpecialOffer(SpecialOffer offer)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
offer.Booked = true;
|
||||||
|
db.UpdateSpecialOffer(offer);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Trace.WriteLine(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool CancelSpecialOffer(SpecialOffer offer)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
client.CancelFlight(offer.FlightTo, offer.Room.RoomType.Capacity);
|
||||||
|
client.CancelFlight(offer.FlightFrom, offer.Room.RoomType.Capacity);
|
||||||
|
offer.Reserverd = false;
|
||||||
|
db.UpdateSpecialOffer(offer);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Trace.WriteLine(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue