continue working on the plattform
This commit is contained in:
parent
828307806e
commit
02cf835575
|
@ -0,0 +1,73 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Plattform.Models;
|
||||
|
||||
namespace Plattform.DB
|
||||
{
|
||||
public class AirportDB
|
||||
{
|
||||
public ICollection<Airport> GetAllAirports()
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
return ctx.Airports.ToList();
|
||||
}
|
||||
}
|
||||
public bool CreateAirport(Airport airport)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
ctx.Airports.Add(airport);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UpdateAirport(Airport airport)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
ctx.Airports.Attach(airport);
|
||||
ctx.Entry(airport).State = System.Data.Entity.EntityState.Modified;
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
public bool DeleteAirport(Airport airport)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
ctx.Airports.Attach(airport);
|
||||
ctx.Airports.Remove(airport);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Plattform.Models;
|
||||
using Plattform.AirlineService;
|
||||
using Plattform;
|
||||
|
||||
namespace Plattform.DB
|
||||
{
|
||||
|
|
|
@ -15,6 +15,10 @@ namespace Plattform.DB
|
|||
public DbSet<Room> Rooms { get; set; }
|
||||
public DbSet<RoomType> RoomTypes { get; set; }
|
||||
public DbSet<Availability> Availabilities { get; set; }
|
||||
public DbSet<Airport> Airports { get; set; }
|
||||
public DbSet<Gender> Genders { get; set; }
|
||||
public DbSet<Salutation> Salutations { get; set; }
|
||||
public DbSet<SpecialOffer> SpecialOffers { get; set; }
|
||||
|
||||
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
||||
{
|
||||
|
@ -45,17 +49,12 @@ namespace Plattform.DB
|
|||
.Property(f => f.Duration)
|
||||
.IsRequired();
|
||||
|
||||
modelBuilder.Entity<Flight>()
|
||||
.Property(f => f.FromCityShortName)
|
||||
.IsRequired();
|
||||
|
||||
modelBuilder.Entity<Flight>()
|
||||
.Property(f => f.StartTime)
|
||||
.IsRequired();
|
||||
|
||||
modelBuilder.Entity<Flight>()
|
||||
.Property(f => f.ToCityShortName)
|
||||
.IsRequired();
|
||||
modelBuilder.Entity<Airport>()
|
||||
.HasKey(f => f.ShortName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Plattform.Models;
|
||||
|
||||
namespace Plattform.DB
|
||||
{
|
||||
public class GenderDB
|
||||
{
|
||||
public ICollection<Gender> GetAllGenders()
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
return ctx.Genders.ToList();
|
||||
}
|
||||
}
|
||||
public bool CreateGender(Gender gender)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
ctx.Genders.Add(gender);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UpdateGender(Gender gender)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
ctx.Genders.Attach(gender);
|
||||
ctx.Entry(gender).State = System.Data.Entity.EntityState.Modified;
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
public bool DeleteGender(Gender gender)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
ctx.Genders.Attach(gender);
|
||||
ctx.Genders.Remove(gender);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Plattform.Models;
|
||||
|
||||
namespace Plattform.DB
|
||||
{
|
||||
public class SalutationDB
|
||||
{
|
||||
public ICollection<Salutation> GetAllSalutations()
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
return ctx.Salutations.ToList();
|
||||
}
|
||||
}
|
||||
public bool CreateSalutation(Salutation salutation)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
ctx.Salutations.Add(salutation);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UpdateSalutation(Salutation salutation)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
ctx.Salutations.Attach(salutation);
|
||||
ctx.Entry(salutation).State = System.Data.Entity.EntityState.Modified;
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
public bool DeleteSalutation(Salutation salutation)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
ctx.Salutations.Attach(salutation);
|
||||
ctx.Salutations.Remove(salutation);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Plattform.Models;
|
||||
|
||||
namespace Plattform.DB
|
||||
{
|
||||
public class SpecialOfferDB
|
||||
{
|
||||
public ICollection<SpecialOffer> GetAllSpecialOffers()
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
return ctx.SpecialOffers.ToList();
|
||||
}
|
||||
}
|
||||
public bool CreateSpecialOffer(SpecialOffer specialOffer)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
ctx.SpecialOffers.Add(specialOffer);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UpdateSpecialOffer(SpecialOffer specialOffer)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
ctx.SpecialOffers.Attach(specialOffer);
|
||||
ctx.Entry(specialOffer).State = System.Data.Entity.EntityState.Modified;
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
public bool DeleteSpecialOffer(SpecialOffer specialOffer)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Context ctx = new Context())
|
||||
{
|
||||
ctx.SpecialOffers.Attach(specialOffer);
|
||||
ctx.SpecialOffers.Remove(specialOffer);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ namespace Plattform.Helper
|
|||
{
|
||||
foreach (var item in ListRoomTypes)
|
||||
{
|
||||
RoomTypes.Add(new RoomType(item));
|
||||
RoomTypes.Add(new RoomType(item, 2, "blubl" ));
|
||||
}
|
||||
return RoomTypes;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace Plattform.Helper
|
|||
{
|
||||
foreach (var item in ListCities)
|
||||
{
|
||||
Cities.Add(new City(item, 3300, "xtz"));
|
||||
Cities.Add(new City(item, 3300));
|
||||
}
|
||||
return Cities;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace Plattform.Models
|
|||
public int AirlineID { get; set; }
|
||||
[DataMember]
|
||||
public string Name { get; set; }
|
||||
|
||||
public Airline(){ }
|
||||
public Airline(AirlineService.Airline airline)
|
||||
{
|
||||
this.Name = airline.Name;
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
using System.Runtime.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Runtime.Serialization;
|
||||
using Plattform;
|
||||
|
||||
namespace Plattfrom.Models
|
||||
namespace Plattform.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Airport
|
||||
|
@ -13,12 +16,18 @@ namespace Plattfrom.Models
|
|||
public string Name { get; set; }
|
||||
[DataMember]
|
||||
public virtual City City { get; set; }
|
||||
|
||||
public Airport() { }
|
||||
public Airport(AirlineService.Airport airport)
|
||||
{
|
||||
City city = new City
|
||||
{
|
||||
Name = airport.City.Name,
|
||||
ZipCode = airport.City.ZipCode,
|
||||
};
|
||||
this.Name = airport.Name;
|
||||
this.City = city;
|
||||
this.ShortName = airport.ShortName;
|
||||
this.City = airport.City;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,10 +13,5 @@ namespace Plattform.Models
|
|||
public DateTime From { get; set; }
|
||||
[DataMember]
|
||||
public DateTime To { get; set; }
|
||||
[DataMember]
|
||||
bool Reserved { get; set; }
|
||||
[DataMember]
|
||||
bool Booked { get; set; }
|
||||
public ICollection<Room> Rooms { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,14 +11,11 @@ namespace Plattform.Models
|
|||
public string Name { get; set; }
|
||||
[DataMember]
|
||||
public int ZipCode { get; set; }
|
||||
[DataMember]
|
||||
public string ShortName { get; set; }
|
||||
public City() { }
|
||||
public City(string name, int zipCode, string shortName)
|
||||
public City(string name, int zipCode)
|
||||
{
|
||||
this.Name = name;
|
||||
this.ZipCode = zipCode;
|
||||
this.ShortName = shortName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using Plattform;
|
||||
|
||||
namespace Plattform.Models
|
||||
{
|
||||
|
@ -23,12 +24,14 @@ namespace Plattform.Models
|
|||
|
||||
public Flight(AirlineService.Flight flight)
|
||||
{
|
||||
Airport origin = new Airport(flight.Origin);
|
||||
Airport destination = new Airport(flight.Destination);
|
||||
this.Airline = new Airline(flight.Airline);
|
||||
this.Name = flight.Name;
|
||||
this.StartTime = flight.StartTime;
|
||||
this.Duration = flight.Duration;
|
||||
this.FromCityShortName = flight.FromCityShortName;
|
||||
this.ToCityShortName = flight.ToCityShortName;
|
||||
this.Origin = origin;
|
||||
this.Destination = destination;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Plattform.Models
|
||||
|
@ -13,6 +14,18 @@ namespace Plattform.Models
|
|||
[DataMember]
|
||||
public Hotel Hotel { get; set; }
|
||||
[DataMember]
|
||||
public ICollection<Availability> Availability { get; set; }
|
||||
public DateTime FreeFrom { get; set; }
|
||||
[DataMember]
|
||||
public DateTime FreeUntil { get; set; }
|
||||
|
||||
public Room() { }
|
||||
public Room(RoomType roomType, Hotel hotel, DateTime freeFrom,
|
||||
DateTime freeUntil)
|
||||
{
|
||||
this.RoomType = roomType;
|
||||
this.Hotel = hotel;
|
||||
this.FreeFrom = freeFrom;
|
||||
this.FreeUntil = freeUntil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Plattform.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class RoomAvailability
|
||||
{
|
||||
[DataMember]
|
||||
public Room Room;
|
||||
[DataMember]
|
||||
public Availability Availability;
|
||||
[DataMember]
|
||||
public Customer Customer;
|
||||
}
|
||||
}
|
|
@ -9,10 +9,17 @@ namespace Plattform.Models
|
|||
public int RoomTypeID { get; set; }
|
||||
[DataMember]
|
||||
public string Name { get; set; }
|
||||
[DataMember]
|
||||
public int Capacity { get; set; }
|
||||
[DataMember]
|
||||
public string Inventory { get; set; }
|
||||
|
||||
public RoomType() { }
|
||||
public RoomType(string name)
|
||||
public RoomType(string name, int capacity, string inventory)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Capacity = capacity;
|
||||
this.Inventory = inventory;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Plattform.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class SpecialOffer
|
||||
{
|
||||
[DataMember]
|
||||
public int SpecialOfferID { get; set; }
|
||||
[DataMember]
|
||||
public virtual Flight Flight { get; set; }
|
||||
[DataMember]
|
||||
public virtual Person Customer { get; set; }
|
||||
[DataMember]
|
||||
public virtual Room Room { get; set; }
|
||||
[DataMember]
|
||||
public float Price { get; set; }
|
||||
[DataMember]
|
||||
public bool Reserverd { get; set; }
|
||||
[DataMember]
|
||||
public DateTime ReservationDate { get; set; }
|
||||
[DataMember]
|
||||
public bool Booked { get; set; }
|
||||
|
||||
public SpecialOffer() { }
|
||||
public SpecialOffer(Flight flight, Room room, float price)
|
||||
{
|
||||
this.Flight = flight;
|
||||
this.Room = room;
|
||||
this.Price = price;
|
||||
this.Reserverd = false;
|
||||
this.Booked = false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -118,14 +118,18 @@
|
|||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Reference.svcmap</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DB\SpecialOfferDB.cs" />
|
||||
<Compile Include="DB\AirportDB.cs" />
|
||||
<Compile Include="DB\AvailabiltyDB.cs" />
|
||||
<Compile Include="DB\AirlineDB.cs" />
|
||||
<Compile Include="DB\GenderDB.cs" />
|
||||
<Compile Include="DB\HotelDB.cs" />
|
||||
<Compile Include="DB\RoomDB.cs" />
|
||||
<Compile Include="DB\RoomTypeDB.cs" />
|
||||
<Compile Include="DB\FlightDB.cs" />
|
||||
<Compile Include="DB\CityDB.cs" />
|
||||
<Compile Include="DB\Context.cs" />
|
||||
<Compile Include="DB\SalutationDB.cs" />
|
||||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -141,13 +145,17 @@
|
|||
</Compile>
|
||||
<Compile Include="IPlattformService.cs" />
|
||||
<Compile Include="Models\Airline.cs" />
|
||||
<Compile Include="Models\Airport.cs" />
|
||||
<Compile Include="Models\Availability.cs" />
|
||||
<Compile Include="Models\City.cs" />
|
||||
<Compile Include="Models\Flight.cs" />
|
||||
<Compile Include="Models\Gender.cs" />
|
||||
<Compile Include="Models\Hotel.cs" />
|
||||
<Compile Include="Models\Person.cs" />
|
||||
<Compile Include="Models\Room.cs" />
|
||||
<Compile Include="Models\RoomAvailability.cs" />
|
||||
<Compile Include="Models\RoomType.cs" />
|
||||
<Compile Include="Models\Saluation.cs" />
|
||||
<Compile Include="Models\SpecialOffer.cs" />
|
||||
<Compile Include="PlattformService.svc.cs">
|
||||
<DependentUpon>PlattformService.svc</DependentUpon>
|
||||
</Compile>
|
||||
|
|
Loading…
Reference in New Issue