From ad230ab0b9a9845164fb3f28b37f4f749379aa3e Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Tue, 28 Aug 2018 21:50:02 +0200 Subject: [PATCH] remove models which are already define in the service --- Plattform/Plattform/DB/AirlineDB.cs | 2 +- Plattform/Plattform/DB/AirportDB.cs | 2 +- Plattform/Plattform/DB/CityDB.cs | 3 +- Plattform/Plattform/DB/Context.cs | 27 ++++++++-------- Plattform/Plattform/DB/FlightDB.cs | 2 +- Plattform/Plattform/Models/Airline.cs | 19 ----------- Plattform/Plattform/Models/Airport.cs | 28 ---------------- Plattform/Plattform/Models/City.cs | 21 ------------ Plattform/Plattform/Models/Flight.cs | 37 ---------------------- Plattform/Plattform/Models/Hotel.cs | 3 +- Plattform/Plattform/Models/SpecialOffer.cs | 10 ++++-- 11 files changed, 27 insertions(+), 127 deletions(-) delete mode 100644 Plattform/Plattform/Models/Airline.cs delete mode 100644 Plattform/Plattform/Models/Airport.cs delete mode 100644 Plattform/Plattform/Models/City.cs delete mode 100644 Plattform/Plattform/Models/Flight.cs diff --git a/Plattform/Plattform/DB/AirlineDB.cs b/Plattform/Plattform/DB/AirlineDB.cs index 103d767..6621310 100644 --- a/Plattform/Plattform/DB/AirlineDB.cs +++ b/Plattform/Plattform/DB/AirlineDB.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using Plattform.Models; +using Plattform.AirlineService; namespace Plattform.DB { diff --git a/Plattform/Plattform/DB/AirportDB.cs b/Plattform/Plattform/DB/AirportDB.cs index 96e3f10..8032d62 100644 --- a/Plattform/Plattform/DB/AirportDB.cs +++ b/Plattform/Plattform/DB/AirportDB.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using Plattform.Models; +using Plattform.AirlineService; namespace Plattform.DB { diff --git a/Plattform/Plattform/DB/CityDB.cs b/Plattform/Plattform/DB/CityDB.cs index 93c9dec..ec49486 100644 --- a/Plattform/Plattform/DB/CityDB.cs +++ b/Plattform/Plattform/DB/CityDB.cs @@ -1,8 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using Plattform.Models; -using Plattform; +using Plattform.AirlineService; namespace Plattform.DB { diff --git a/Plattform/Plattform/DB/Context.cs b/Plattform/Plattform/DB/Context.cs index 77df345..6b2e690 100644 --- a/Plattform/Plattform/DB/Context.cs +++ b/Plattform/Plattform/DB/Context.cs @@ -1,6 +1,7 @@ using System.Data.Entity; using Plattform.Models; using Plattform.Helper; +using Plattform.AirlineService; namespace Plattform.DB { @@ -8,53 +9,53 @@ namespace Plattform.DB { public Context() : base("PlattformDB") { } - public DbSet Cities { get; set; } - public DbSet Airlines { get; set; } - public DbSet Flights { get; set; } + public DbSet Cities { get; set; } + public DbSet Airlines { get; set; } + public DbSet Flights { get; set; } public DbSet Hotels { get; set; } public DbSet Rooms { get; set; } public DbSet RoomTypes { get; set; } public DbSet Availabilities { get; set; } - public DbSet Airports { get; set; } + public DbSet Airports { get; set; } public DbSet Genders { get; set; } public DbSet Salutations { get; set; } public DbSet SpecialOffers { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { - modelBuilder.Entity() + modelBuilder.Entity() .Property(c => c.Name) .HasMaxLength(50) .IsRequired(); - modelBuilder.Entity() + modelBuilder.Entity() .Property(c => c.ZipCode) .IsRequired() .IsUnique(); - modelBuilder.Entity() + modelBuilder.Entity() .Property(a => a.AirlineID) .IsRequired() .IsUnique(); - modelBuilder.Entity() + modelBuilder.Entity() .Property(a => a.Name) .IsRequired(); - modelBuilder.Entity() + modelBuilder.Entity() .Property(f => f.Name) .IsRequired(); - modelBuilder.Entity() + modelBuilder.Entity() .Property(f => f.Duration) .IsRequired(); - modelBuilder.Entity() + modelBuilder.Entity() .Property(f => f.StartTime) .IsRequired(); - modelBuilder.Entity() + modelBuilder.Entity() .HasKey(f => f.ShortName); } } -} \ No newline at end of file +} diff --git a/Plattform/Plattform/DB/FlightDB.cs b/Plattform/Plattform/DB/FlightDB.cs index f444b66..36f02c7 100644 --- a/Plattform/Plattform/DB/FlightDB.cs +++ b/Plattform/Plattform/DB/FlightDB.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using Plattform.Models; +using Plattform.AirlineService; namespace Plattform.DB { diff --git a/Plattform/Plattform/Models/Airline.cs b/Plattform/Plattform/Models/Airline.cs deleted file mode 100644 index d11a1d0..0000000 --- a/Plattform/Plattform/Models/Airline.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Runtime.Serialization; - -namespace Plattform.Models -{ - [DataContract] - public class Airline - { - [DataMember] - public int AirlineID { get; set; } - [DataMember] - public string Name { get; set; } - - public Airline(){ } - public Airline(AirlineService.Airline airline) - { - this.Name = airline.Name; - } - } -} diff --git a/Plattform/Plattform/Models/Airport.cs b/Plattform/Plattform/Models/Airport.cs deleted file mode 100644 index 3250581..0000000 --- a/Plattform/Plattform/Models/Airport.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Runtime.Serialization; - -namespace Plattform.Models -{ - [DataContract] - public class Airport - { - [DataMember] - public string ShortName { get; set; } - [DataMember] - 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; - } - } -} diff --git a/Plattform/Plattform/Models/City.cs b/Plattform/Plattform/Models/City.cs deleted file mode 100644 index 9d0d867..0000000 --- a/Plattform/Plattform/Models/City.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Runtime.Serialization; - -namespace Plattform.Models -{ - [DataContract] - public class City - { - [DataMember] - public int CityID { get; set; } - [DataMember] - public string Name { get; set; } - [DataMember] - public int ZipCode { get; set; } - public City() { } - public City(string name, int zipCode) - { - this.Name = name; - this.ZipCode = zipCode; - } - } -} diff --git a/Plattform/Plattform/Models/Flight.cs b/Plattform/Plattform/Models/Flight.cs deleted file mode 100644 index 3be235e..0000000 --- a/Plattform/Plattform/Models/Flight.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Runtime.Serialization; -using Plattform; - -namespace Plattform.Models -{ - [DataContract] - public class Flight - { - [DataMember] - public int FlightID { get; set; } - [DataMember] - public virtual Airline Airline { get; set; } - [DataMember] - public string Name { get; set; } - [DataMember] - public DateTime StartTime { get; set; } - [DataMember] - public float Duration { get; set; } - [DataMember] - public virtual Airport Origin { get; set; } - [DataMember] - public virtual Airport Destination { get; set; } - - 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.Origin = origin; - this.Destination = destination; - } - } -} diff --git a/Plattform/Plattform/Models/Hotel.cs b/Plattform/Plattform/Models/Hotel.cs index 1faf5e4..62b39d3 100644 --- a/Plattform/Plattform/Models/Hotel.cs +++ b/Plattform/Plattform/Models/Hotel.cs @@ -1,4 +1,5 @@ using System.Runtime.Serialization; +using Plattform; namespace Plattform.Models { @@ -10,6 +11,6 @@ namespace Plattform.Models [DataMember] public string Name { get; set; } [DataMember] - public virtual City City { get; set; } + public virtual AirlineService.City City { get; set; } } } diff --git a/Plattform/Plattform/Models/SpecialOffer.cs b/Plattform/Plattform/Models/SpecialOffer.cs index bb74208..6d9209e 100644 --- a/Plattform/Plattform/Models/SpecialOffer.cs +++ b/Plattform/Plattform/Models/SpecialOffer.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Runtime.Serialization; +using Plattform.AirlineService; namespace Plattform.Models { @@ -10,7 +11,9 @@ namespace Plattform.Models [DataMember] public int SpecialOfferID { get; set; } [DataMember] - public virtual Flight Flight { get; set; } + public virtual Flight FlightTo { get; set; } + [DataMember] + public virtual Flight FlightFrom { get; set; } [DataMember] public virtual Person Customer { get; set; } [DataMember] @@ -25,9 +28,10 @@ namespace Plattform.Models public bool Booked { get; set; } public SpecialOffer() { } - public SpecialOffer(Flight flight, Room room, float price) + public SpecialOffer(Flight flightTo, Flight flightFrom, Room room, float price) { - this.Flight = flight; + this.FlightTo = flightTo; + this.FlightFrom = flightFrom; this.Room = room; this.Price = price; this.Reserverd = false;