This commit is contained in:
Andreas Zweili 2018-08-13 19:31:42 +02:00
parent f0eaa2ac62
commit 6459ef961c
10 changed files with 60 additions and 14 deletions

View File

@ -7,14 +7,18 @@ namespace Plattform.Helper
{
protected override void Seed(Context context)
{
var cities = GenerateData.CreateCities();
//var cities = GenerateData.CreateCities();
var types = GenerateData.CreateRoomTypes();
foreach (var c in cities)
//foreach (var c in cities)
//{
// context.Cities.Add(c);
//}
foreach (var t in types)
{
context.Cities.Add(c);
context.RoomTypes.Add(t);
}
context.SaveChanges();
}
}
}

View File

@ -7,9 +7,30 @@ namespace Plattform.Helper
{
public static class GenerateData
{
private static ICollection<City> Cities;
public static ICollection<City> CreateCities()
private static List<City> Cities = new List<City>();
private static List<RoomType> RoomTypes = new List<RoomType>();
private static List<string> ListRoomTypes = new List<string>(new string[]
{
"Single Bed", "Double Bed", "Suite"
});
private static List<string> ListCities = new List<string>(new string[]
{
"Bern"
});
public static List<RoomType> CreateRoomTypes()
{
foreach (var item in ListRoomTypes)
{
RoomTypes.Add(new RoomType(item));
}
return RoomTypes;
}
public static List<City> CreateCities()
{
foreach (var item in ListCities)
{
Cities.Add(new City(item, 3300, "xtz"));
}
return Cities;
}
}

View File

@ -19,4 +19,4 @@ namespace Plattform.Models
this.Name = airline.Name;
}
}
}
}

View File

@ -13,6 +13,10 @@ 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; }
}
}
}

View File

@ -13,5 +13,12 @@ namespace Plattform.Models
public int ZipCode { get; set; }
[DataMember]
public string ShortName { get; set; }
public City() { }
public City(string name, int zipCode, string shortName)
{
this.Name = name;
this.ZipCode = zipCode;
this.ShortName = shortName;
}
}
}
}

View File

@ -31,4 +31,4 @@ namespace Plattform.Models
this.ToCityShortName = flight.ToCityShortName;
}
}
}
}

View File

@ -12,4 +12,4 @@ namespace Plattform.Models
[DataMember]
public City City { get; set; }
}
}
}

View File

@ -15,4 +15,4 @@ namespace Plattform.Models
[DataMember]
public ICollection<Availability> Availability { get; set; }
}
}
}

View File

@ -2,9 +2,14 @@
namespace Plattform.Models
{
[DataContract]
public class RoomAvailability
{
[DataMember]
public Room Room;
[DataMember]
public Availability Availability;
[DataMember]
public Customer Customer;
}
}
}

View File

@ -9,5 +9,10 @@ namespace Plattform.Models
public int RoomTypeID { get; set; }
[DataMember]
public string Name { get; set; }
public RoomType() { }
public RoomType(string name)
{
this.Name = name;
}
}
}
}