public ResultDto Update([FromBody] TruckTypeDto model) { if (!ModelState.IsValid) { return new ResultDto { Success = false, Message = "Não foi possível alterar os dados do caminhão." } } ; var update = new TruckType(model.TruckTypeId, model.Name); _repository.Update(update); var resultTruckTypeDto = new ResultTruckTypeDto(update.TruckTypeId, update.Name); return(new ResultDto { Success = true, Message = "Dados atualizados com sucesso.", Data = resultTruckTypeDto }); } }
public TruckType GetTruckTypeRecord(string recordID, string UserSNo) { TruckType TruckType = new TruckType(); SqlDataReader dr = null; try { SqlParameter[] Parameters = { new SqlParameter("@SNo", recordID), new SqlParameter("@UserID", Convert.ToInt32(UserSNo)) }; dr = SqlHelper.ExecuteReader(DMLConnectionString.WebConfigConnectionString, CommandType.StoredProcedure, "GetRecordTruckType", Parameters); if (dr.Read()) { TruckType.SNo = Convert.ToInt32(recordID); TruckType.IsActive = Convert.ToBoolean(dr["IsActive"]); if (!String.IsNullOrEmpty(dr["IsActive"].ToString())) { TruckType.IsActive = Convert.ToBoolean(dr["IsActive"]); TruckType.Active = dr["Active"].ToString().ToUpper(); } TruckType.Name = Convert.ToString(dr["Name"]).ToUpper(); TruckType.UpdatedBy = dr["UpdatedUser"].ToString(); TruckType.CreatedBy = dr["CreatedUser"].ToString(); } } catch (Exception ex)// { dr.Close(); throw ex; } return(TruckType); }
private async void bookBtn_Click(object sender, EventArgs e) { TruckType type = await db.GetTruckTypeById((int)slctTruckBox.SelectedValue); //List<Truck> trucks = await db.GetAvailiableTrucks(type); try { Truck truck = await db.GetNextAvailableTruck(type); List <User> users = await db.GetAvailibleDrivers();//[0]; User user = users[0]; Route route = await db.GetRouteByID((int)destinationBox.SelectedValue); TripStatus status = await db.GetTripStatusByID(0); Customer customer = await db.GetCustomerByID((int)cmbCustomers.SelectedValue); Trip trip = new Trip(truck, customer, (DateTime)dateTimePicker.Value, (DateTime)dateTimePicker.Value.AddDays(3), user, route, status); trip = await db.BookTrip(trip); MessageBox.Show($"Trip booked for {trip.Start} with Truck {trip.Truck.ID}"); } catch (Exception ex) { MessageBox.Show(ex.Message); MessageBox.Show("Next availible date: " + await db.NextAvailibleDate(type)); return; } this.Close(); }
/// <summary cref="IEncodeable.IsEqual(IEncodeable)" /> public override bool IsEqual(IEncodeable encodeable) { if (Object.ReferenceEquals(this, encodeable)) { return(true); } TruckType value = encodeable as TruckType; if (value == null) { return(false); } if (!base.IsEqual(encodeable)) { return(false); } if (!Utils.IsEqual(m_cargoCapacity, value.m_cargoCapacity)) { return(false); } return(true); }
public void Update_BadTruckType_Throws(TruckType truckType) { var model = new Truck { Id = Guid.NewGuid(), TruckType = TruckType.FH, ModelYear = DateTime.Now.Year, FabricationYear = DateTime.Now.Year, Name = "Truck", Plate = "AAA0000" }; using var context = this.BuildContext(); context.Trucks.Add(model); context.SaveChanges(); var subject = this.BuildService(context); Assert.Throws <ValidationException>(() => subject.Update(model.Id.ToString(), new UpdateTruckInput { TruckType = truckType, ModelYear = DateTime.Now.Year, FabricationYear = DateTime.Now.Year, Name = "Truck", Plate = "AAA0000" })); }
private void SaveTruckType() { try { if (truckTypeId == 0) { var truckType = new TruckType { TruckTypeId = truckTypeId, TruckTypeDesc = txtTruckTypeName.Text.Trim(), Active = chkActive.Checked, CreateBy = "system", }; TruckTypeController.Insert(truckType); } else { var truckType = new TruckType { TruckTypeId = this.truckTypeId, TruckTypeDesc = txtTruckTypeName.Text.Trim(), Active = chkActive.Checked, ModifiedBy = "system", }; truckType.TruckTypeId = Convert.ToInt32(txtTruckTypeId.Text); TruckTypeController.Update(truckType); } } catch (Exception) { throw; } }
public Trucks(TruckType typeOfTruck, int year, string color, Towing towing) { TypeOfTruck = typeOfTruck;//I don't understand this naming Year = year; Color = color; Towing = towing; }
public ResultDto Add([FromBody] TruckTypeDto model) { if (!ModelState.IsValid) { return new ResultDto { Success = false, Message = "Não foi possível cadastrar caminhão." } } ; var truckType = new TruckType(model.TruckTypeId, model.Name); _repository.Add(truckType); var resultTruckTypeDto = new ResultTruckTypeDto(truckType.TruckTypeId, truckType.Name); return(new ResultDto { Success = true, Message = "Caminhão cadastrado com sucesso.", Data = resultTruckTypeDto }); }
public async Task <List <FreightDTO> > GetFreightListAsync() { try { List <Freight> data = await _repFreight.GetAllAsQueryable().ToListAsync(); List <FreightDTO> datas = new List <FreightDTO>(); foreach (var item in data) { FreightDTO freightDTO = new FreightDTO(); freightDTO.ID = item.ID; freightDTO.BaseTruckRent = item.BaseTruckRent; freightDTO.SourceCityId = item.SourceCityId; City city = _repCity.GetAllAsQueryable().Where(c => c.Code == item.SourceCityId).FirstOrDefault(); freightDTO.SourceCityName = city.CityName; freightDTO.DestinationCityId = item.DestinationCityId; City cityDes = _repCity.GetAllAsQueryable().Where(c => c.Code == item.DestinationCityId).FirstOrDefault(); freightDTO.DestinationCityName = cityDes.CityName; freightDTO.CreateDate = item.CreateDate; freightDTO.LoadDate = item.LoadDate; freightDTO.LoadTime = item.LoadTime; freightDTO.ExpireDate = item.ExpireDate; freightDTO.ExpireTime = item.ExpireTime; freightDTO.PackageType = item.PackageType; freightDTO.GoodName = item.GoodName; PackageType packageType = _repPackageType.GetAllAsQueryable().Where(c => c.ID == item.PackageType).FirstOrDefault(); freightDTO.PackageName = packageType.Name; freightDTO.TruckType = item.TruckType; TruckType truckType = _repTruckType.GetAllAsQueryable().Where(c => c.ID == item.TruckType).FirstOrDefault(); freightDTO.TruckName = truckType.Name; freightDTO.LoaderType = item.LoaderType; Loader loader = _repLoader.GetAllAsQueryable().Where(c => c.ID == item.LoaderType).FirstOrDefault(); freightDTO.loaderName = loader.Name; freightDTO.Weight = item.Weight; freightDTO.Description = item.Description; freightDTO.Tell = item.Tell; freightDTO.BaseTruckRent = item.BaseTruckRent; freightDTO.BaseTruckRent = item.BaseTruckRent; datas.Add(freightDTO); } return(datas); } catch (Exception e) { throw new ServiceExeption(e.Message, e); } }
/// <summary> /// Spawn a new truck on the center of the AR board /// </summary> /// <param name="truck"></param> private void SpawnTruck(TruckType truck) { DespawnTruck(mainTruck); MessageBroker.Default.Publish(new SpawnTruckMessage() { Type = truck, Truck = OnTruckReceived }); }
/// <summary cref="Object.MemberwiseClone" /> public new object MemberwiseClone() { TruckType clone = (TruckType)base.MemberwiseClone(); clone.m_cargoCapacity = (uint)Utils.Clone(this.m_cargoCapacity); return(clone); }
public ActionResult DeleteConfirmed(int id) { TruckType truckType = db.TruckTypes.Find(id); db.TruckTypes.Remove(truckType); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,TruckTypeName")] TruckType truckType) { if (ModelState.IsValid) { db.Entry(truckType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(truckType)); }
private async void AddTruckBtn_Click(object sender, EventArgs e) { string Vin = vinTxtBox.Text; string Reg = regTxtBox.Text; int Kms = Convert.ToInt32(mileageBox.Text); TruckType type = await db.GetTruckTypeById((int)typeComboBox.SelectedValue); Truck truck = new Truck(Vin, Reg, Kms, true, type); db.AddTruck(truck); }
public ActionResult Create([Bind(Include = "Id,TruckTypeName")] TruckType truckType) { if (ModelState.IsValid) { db.TruckTypes.Add(truckType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(truckType)); }
public Truck(TruckType NewTruckType) { TypeOfTruck = NewTruckType; Guid Id = Guid.NewGuid(); List<IVehicleTire> Tires = new List<IVehicleTire>(); for(int i=0;i==3;i++) { //Create 4 tires TruckTire currentTire = new TruckTire(this, i); _tires.Add(currentTire); } }
public Truck(TruckType NewTruckType) { TypeOfTruck = NewTruckType; Guid Id = Guid.NewGuid(); List <IVehicleTire> Tires = new List <IVehicleTire>(); for (int i = 0; i == 3; i++) { //Create 4 tires TruckTire currentTire = new TruckTire(this, i); _tires.Add(currentTire); } }
// GET: TruckType/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TruckType truckType = db.TruckTypes.Find(id); if (truckType == null) { return(HttpNotFound()); } return(View(truckType)); }
/// <summary> /// Truck routing only, specifies the vehicle type.Defaults to truck. /// </summary> /// <param name="tpParams"></param> /// <param name="valeur">Enum [truck | tractorTruck]</param> public static void AddTruckType(this RouteTruckOptions tpParams, TruckType valeur) { if (tpParams == null) { throw new ArgumentNullException(nameof(tpParams)); } string nom = "truckType"; var param = new ParamsEnum <TruckType>(nom, valeur); if (!tpParams.Parametres.TryAdd(nom, param)) { tpParams.Parametres.Remove(nom); tpParams.Parametres.Add(nom, param); } }
private void LoadData() { try { if (this.truckTypeId > 0) { TruckType truckType = TruckTypeController.GetTruckType(this.truckTypeId); txtTruckTypeId.Text = this.truckTypeId.ToString();; txtTruckTypeName.Text = truckType.TruckTypeDesc; chkActive.Checked = truckType.Active; BtnSaveAndNew.Visible = false; //txtTruckNo.Enabled = false; } } catch (Exception) { } }
public async Task GetTruckTypeByNameAsync_WithNullTypeName_ShouldRetyrnArgumentNullException() { var context = SteuDbContextInMemoryFactory.InitializeContext(); var service = this.IntializeTruckTypesService(context); var repository = new EfRepository <TruckType>(context); var truckType = new TruckType() { Name = "Normal", }; await repository.AddAsync(truckType); await repository.SaveChangesAsync(); await Assert.ThrowsAsync <ArgumentNullException>(() => service.GetTruckTypeByNameAsync(null)); }
// Setup the vehicle based on the type of truck it is. Every truck is // required to have a name. public Vehicle(TruckType truckType, string truckName) { this.truckName = truckName; this.truckType = truckType; txFreq_medic = 40; rxFreq_medic = 40; txFreq_command = 45; rxFreq_command = 45; txFreq_sat = 300000; rxFreq_sat = 350000; txFreq_special = 50; rxFreq_special = 50; txFreq_ops = 55; rxFreq_ops = 55; RadiosInTruckByType(); }
public ActionResult GridViewUpdate([ModelBinder(typeof(XpoModelBinder))] TruckType item) { using (UnitOfWork uow = new UnitOfWork()) { var model = uow.Query <TruckType>(); if (ModelState.IsValid) { if (item.IsChanged) { item.Save(); } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_GridViewPartial", model.ToList())); } }
public async Task GetAllTruckTypesAsyncTest_WithData_RreturnListOfTruckTypes() { var context = SteuDbContextInMemoryFactory.InitializeContext(); var service = this.IntializeTruckTypesService(context); var repository = new EfRepository <TruckType>(context); var truckType = new TruckType() { Name = "Normal", }; await repository.AddAsync(truckType); await repository.SaveChangesAsync(); var actualResult = await service.GetAllTruckTypesAsync <AllTruckTypesTruckEditViewModel>(); Assert.Single(actualResult); }
public async Task GetTruckTypeByNameAsync_WithValidTruckTypeName_RreturnTruckType() { var context = SteuDbContextInMemoryFactory.InitializeContext(); var service = this.IntializeTruckTypesService(context); var repository = new EfRepository <TruckType>(context); var truckType = new TruckType() { Name = "Normal", }; await repository.AddAsync(truckType); await repository.SaveChangesAsync(); var actualResult = await service.GetTruckTypeByNameAsync("Normal"); Assert.Equal("Normal", actualResult.Name); }
public ActionResult GridViewAddNew([ModelBinder(typeof(XpoModelBinder))] TruckType item) { using (UnitOfWork uow = new UnitOfWork()) { var model = uow.Query <TruckType>(); if (ModelState.IsValid) { var truckType = new TruckType(uow) { Type = item.Type }; uow.CommitChanges(); } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_GridViewPartial", model.ToList())); } }
private List <Truck> GenerateTrucks(TruckType type) { var trucks = new List <Truck>(); for (var i = 0; i < 5; i++) { var truck = new Truck { Places = new List <Place>() }; for (var j = 0; j < 50; j++) { truck.Places.Add(new Place { Id = j, Reserved = _random.Next(0, 2) == 1 }); } trucks.Add(truck); } return(trucks); }
public void Create_BadTruckType_Throws(TruckType truckType) { var model = new Truck { Id = Guid.NewGuid(), TruckType = TruckType.FH, ModelYear = DateTime.Now.Year, FabricationYear = DateTime.Now.Year, Name = "Truck", Plate = "AAA0000" }; using var context = this.BuildContext(); var subject = this.BuildService(context); Assert.Throws <ValidationException>(() => subject.Create(new CreateTruckInput { TruckType = truckType, ModelYear = DateTime.Now.Year, FabricationYear = DateTime.Now.Year, Name = "Truck", Plate = "AAA0000" })); }
public static void Initialize(TrnspMngmntContext context) { context.Database.EnsureCreated(); // Look for any students. if (context.Cargoes.Any()) { return; // DB has been seeded } var trucktypes = new TruckType[] { new TruckType { TruckTypeID = 10, TypeName = "Tilt" }, new TruckType { TruckTypeID = 11, TypeName = "Refrigirator" }, new TruckType { TruckTypeID = 12, TypeName = "Metal Trailer" }, new TruckType { TruckTypeID = 13, TypeName = "Insulated Truck" }, new TruckType { TruckTypeID = 14, TypeName = "Car transporter" } }; foreach (TruckType c in trucktypes) { context.TruckTypes.Add(c); } context.SaveChanges(); //var companies = new Company[] //{ // new Company{Name="WhatisloveCorp",Email="*****@*****.**",Phone="+380963083105"}, // new Company{Name="VicitalCorp",Email="*****@*****.**",Phone="+380502052146"}, // new Company{Name="ViktoriaCorp",Email="*****@*****.**",Phone="+380963073808"} //}; //foreach (Company c in companies) //{ // context.Companies.Add(c); //} //context.SaveChanges(); //var cargos = new Cargo[] //{ //new Cargo{StartOfShipping=DateTime.Parse("2019-05-02"),EndOfShipping=DateTime.Parse("2019-06-02"),Departure="Vinnitsia", // Destination ="Kyiv",Info="Details",Weight=10000,Volume=123, // CompanyID =companies.Single(i=>i.Name=="WhatisloveCorp").Id,TruckTypeID=10}, //new Cargo{StartOfShipping=DateTime.Parse("2019-05-03"),EndOfShipping=DateTime.Parse("2019-06-03"),Departure="Zaporizzia", // Destination ="Kyiv",Info="Milk",Weight=1000,Volume=100, // CompanyID =companies.Single(i=>i.Name=="WhatisloveCorp").Id,TruckTypeID=11}, //new Cargo{StartOfShipping=DateTime.Parse("2019-05-04"),EndOfShipping=DateTime.Parse("2019-06-04"),Departure="Vinnitsia", // Destination ="Lviv",Info="Choklate",Weight=15000,Volume=90, // CompanyID =companies.Single(i=>i.Name=="ViktoriaCorp").Id,TruckTypeID=11}, //new Cargo{StartOfShipping=DateTime.Parse("2019-07-02"),EndOfShipping=DateTime.Parse("2019-08-02"),Departure="Kherson", // Destination ="Odessa",Info="Souseges",Weight=9000,Volume=20, // CompanyID =companies.Single(i=>i.Name=="VicitalCorp").Id, // TruckTypeID =12}, //new Cargo{StartOfShipping=DateTime.Parse("2019-08-02"),EndOfShipping=DateTime.Parse("2019-08-02"),Departure="Zhytomyr", // Destination ="Simpheropol",Info="Armor",Weight=70000,Volume=50, // CompanyID =companies.Single(i=>i.Name=="ViktoriaCorp").Id,TruckTypeID=14} //}; //foreach (Cargo s in cargos) //{ // context.Cargoes.Add(s); //} //context.SaveChanges(); //var transports = new Transport[] //{ //new Transport{StartOfShipping=DateTime.Parse("2019-05-02"),EndOfShipping=DateTime.Parse("2019-06-02"),Departure="Zaporizzia",Destination="Vinnitsia",MaxWeight=10000,MaxVolume=123,CompanyID=companies.Single(i=>i.Name=="ViktoriaCorp").Id,TruckTypeID=10,Type=Models.Type.Truck}, //new Transport{StartOfShipping=DateTime.Parse("2019-05-03"),EndOfShipping=DateTime.Parse("2019-06-03"),Departure="Zaporizzia",Destination="Kyiv",MaxWeight=1000,MaxVolume=100,CompanyID=companies.Single(i=>i.Name=="WhatisloveCorp").Id,TruckTypeID=11,Type=Models.Type.Semitrailer}, //new Transport{StartOfShipping=DateTime.Parse("2019-05-04"),EndOfShipping=DateTime.Parse("2019-05-07"),Departure="Vinnitsia",Destination="Lviv",MaxWeight=15000,MaxVolume=90,CompanyID=companies.Single(i=>i.Name=="VicitalCorp").Id,TruckTypeID=11,Type=Models.Type.Truck}, //new Transport{StartOfShipping=DateTime.Parse("2019-07-05"),EndOfShipping=DateTime.Parse("2019-07-06"),Departure="Mykolaiv",Destination="Odessa",MaxWeight=9000,MaxVolume=20,CompanyID=companies.Single(i=>i.Name=="VicitalCorp").Id,TruckTypeID=12,Type=Models.Type.DoubleRoadTrain}, //new Transport{StartOfShipping=DateTime.Parse("2019-08-04"),EndOfShipping=DateTime.Parse("2019-09-05"),Departure="Zhytomyr",Destination="Simpheropol",MaxWeight=70000,MaxVolume=50,CompanyID=companies.Single(i=>i.Name=="ViktoriaCorp").Id,TruckTypeID=14,Type=Models.Type.DoubleRoadTrain} //}; //foreach (Transport s in transports) //{ // context.Transports.Add(s); //} //context.SaveChanges(); }
public async Task <List <FreightDTO> > GetFreightListAsync(FilterFreightDTO filter) { try { var query = _repFreight.GetAllAsQueryable(); if (filter.DestinationCityId > 0) { int IntegerDestination = (filter.DestinationCityId) / 1000000; query = query.Where(c => (c.DestinationCityId) / 1000000 == IntegerDestination); } if (filter.SourceCityId > 0) { int IntegerSource = (filter.SourceCityId) / 1000000; query = query.Where(c => (c.SourceCityId) / 1000000 == IntegerSource); } if (filter.Weight >= 3) { query = query.Where(c => c.Weight >= 3); } else if (filter.Weight < 3 && filter.Weight > 1) { query = query.Where(c => c.Weight < 3); } if (filter.LoadDate != null) { query = query.Where(c => string.Compare(c.LoadDate, filter.LoadDate) >= 0); } if (filter.ExpireDate != null) { query = query.Where(c => string.Compare(c.ExpireDate, filter.ExpireDate) <= 0); } List <Freight> data = await query.ToListAsync(); List <FreightDTO> datas = new List <FreightDTO>(); foreach (var item in data) { FreightDTO freightDTO = new FreightDTO(); freightDTO.ID = item.ID; freightDTO.BaseTruckRent = item.BaseTruckRent; freightDTO.SourceCityId = item.SourceCityId; City city = _repCity.GetAllAsQueryable().Where(c => c.Code == item.SourceCityId).FirstOrDefault(); freightDTO.SourceCityName = city.CityName; freightDTO.DestinationCityId = item.DestinationCityId; City cityDes = _repCity.GetAllAsQueryable().Where(c => c.Code == item.DestinationCityId).FirstOrDefault(); freightDTO.DestinationCityName = cityDes.CityName; freightDTO.CreateDate = item.CreateDate; freightDTO.LoadDate = item.LoadDate; freightDTO.LoadTime = item.LoadTime; freightDTO.ExpireDate = item.ExpireDate; freightDTO.ExpireTime = item.ExpireTime; freightDTO.PackageType = item.PackageType; freightDTO.GoodName = item.GoodName; PackageType packageType = _repPackageType.GetAllAsQueryable().Where(c => c.ID == item.PackageType).FirstOrDefault(); freightDTO.PackageName = packageType.Name; freightDTO.TruckType = item.TruckType; TruckType truckType = _repTruckType.GetAllAsQueryable().Where(c => c.ID == item.TruckType).FirstOrDefault(); freightDTO.TruckName = truckType.Name; freightDTO.LoaderType = item.LoaderType; Loader loader = _repLoader.GetAllAsQueryable().Where(c => c.ID == item.LoaderType).FirstOrDefault(); freightDTO.loaderName = loader.Name; freightDTO.Weight = item.Weight; freightDTO.Description = item.Description; freightDTO.Tell = item.Tell; freightDTO.BaseTruckRent = item.BaseTruckRent; freightDTO.BaseTruckRent = item.BaseTruckRent; datas.Add(freightDTO); } return(datas); } catch (Exception e) { throw new ServiceExeption(e.Message, e); } }
protected override void Seed(CoffeeSoft.Models.CoffeeSoftDbContext context) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. E.g. // // context.People.AddOrUpdate( // p => p.FullName, // new Person { FullName = "Andrew Peters" }, // new Person { FullName = "Brice Lambson" }, // new Person { FullName = "Rowan Miller" } // ); // var trucktype1 = new TruckType { TruckTypeName = "Samochód osobowy", Trucks = new List <Truck>() }; context.TruckTypes.AddOrUpdate(i => i.TruckTypeName, trucktype1, new TruckType { TruckTypeName = "Ciężarówka", Trucks = new List <Truck>() }, new TruckType { TruckTypeName = "TIR", Trucks = new List <Truck>() }); context.StatusTypes.AddOrUpdate(i => i.StatusName, new StatusType { StatusName = "Do akceptacji", Orders = new List <Order>() }, new StatusType { StatusName = "Zaakceptowane", Orders = new List <Order>() }, new StatusType { StatusName = "Zrealizowane", Orders = new List <Order>() }); context.ItemTypes.AddOrUpdate(i => i.ItemsName, new ItemType { ItemsName = "Kawa ziarnista", Items = new List <Item>() }, new ItemType { ItemsName = "Kawa zmielona", Items = new List <Item>() }, new ItemType { ItemsName = "Kubki ceramiczne", Items = new List <Item>() }, new ItemType { ItemsName = "Kubki termiczne", Items = new List <Item>() }, new ItemType { ItemsName = "Herbata liściasta", Items = new List <Item>() }); context.PaymentTypes.AddOrUpdate(i => i.PaymentName, new PaymentType { PaymentName = "Płatność przy odbiorze", Orders = new List <Order>() }, new PaymentType { PaymentName = "Przedpłata", Orders = new List <Order>() }); var type1 = new WarehouseType() { WarehouseTypeName = "Magazyn otwarty", Warehouses = new List <Warehouse>() }; context.WarehouseTypes.AddOrUpdate(i => i.WarehouseTypeName, type1, new WarehouseType { WarehouseTypeName = "Magazyn zamknięty", Warehouses = new List <Warehouse>() }, new WarehouseType { WarehouseTypeName = "Magazyn półotwarty", Warehouses = new List <Warehouse>() }); context.SaveChanges(); if (!context.Warehouses.Any()) { context.Warehouses.AddOrUpdate(i => i.WarehouseName, new Warehouse { WarehouseName = "Koluszki", WarehouseType = type1, OrderList = new List <Order>(), InvoiceList = new List <Invoice>(), CoffeeShopList = new List <CoffeeShop>() }); } if (!context.Trucks.Any()) { context.Trucks.AddOrUpdate(i => i.TruckName, new Truck { TruckName = "Yaris", TruckType = trucktype1, Orders = new List <Order>(), Brand = "Toyota", RegistrationNo = "SWA 1234", }); } context.SaveChanges(); }