remove models which are already define in the service

This commit is contained in:
Andreas Zweili 2018-08-28 21:50:02 +02:00
parent 0e1ef33782
commit ad230ab0b9
11 changed files with 27 additions and 127 deletions

View File

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Plattform.Models;
using Plattform.AirlineService;
namespace Plattform.DB
{

View File

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Plattform.Models;
using Plattform.AirlineService;
namespace Plattform.DB
{

View File

@ -1,8 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Plattform.Models;
using Plattform;
using Plattform.AirlineService;
namespace Plattform.DB
{

View File

@ -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<City> Cities { get; set; }
public DbSet<Airline> Airlines { get; set; }
public DbSet<Flight> Flights { get; set; }
public DbSet<AirlineService.City> Cities { get; set; }
public DbSet<AirlineService.Airline> Airlines { get; set; }
public DbSet<AirlineService.Flight> Flights { get; set; }
public DbSet<Hotel> Hotels { get; set; }
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<AirlineService.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)
{
modelBuilder.Entity<City>()
modelBuilder.Entity<AirlineService.City>()
.Property(c => c.Name)
.HasMaxLength(50)
.IsRequired();
modelBuilder.Entity<City>()
modelBuilder.Entity<AirlineService.City>()
.Property(c => c.ZipCode)
.IsRequired()
.IsUnique();
modelBuilder.Entity<Airline>()
modelBuilder.Entity<AirlineService.Airline>()
.Property(a => a.AirlineID)
.IsRequired()
.IsUnique();
modelBuilder.Entity<Airline>()
modelBuilder.Entity<AirlineService.Airline>()
.Property(a => a.Name)
.IsRequired();
modelBuilder.Entity<Flight>()
modelBuilder.Entity<AirlineService.Flight>()
.Property(f => f.Name)
.IsRequired();
modelBuilder.Entity<Flight>()
modelBuilder.Entity<AirlineService.Flight>()
.Property(f => f.Duration)
.IsRequired();
modelBuilder.Entity<Flight>()
modelBuilder.Entity<AirlineService.Flight>()
.Property(f => f.StartTime)
.IsRequired();
modelBuilder.Entity<Airport>()
modelBuilder.Entity<AirlineService.Airport>()
.HasKey(f => f.ShortName);
}
}
}
}

View File

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Plattform.Models;
using Plattform.AirlineService;
namespace Plattform.DB
{

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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; }
}
}

View File

@ -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;