public ActionResult New() { PlaneViewModel vmPlane = new PlaneViewModel(); _PreferenceRepository.LoadBasePreferences(vmPlane); return(View(vmPlane)); }
private Dictionary <int, int> Configure(PlaneConfiguration configuration) { PlaneViewModel plane = configuration.Plane; Dictionary <int, int> config = Enumerable.Range(0, Convert.ToInt32(Math.Ceiling(FlightPlanificator.PassengerDemand.TotalPax / plane.Capacity / 2))) .ToDictionary(i => i, i => i * plane.Capacity * 2); return(config); }
public static void Load() { RuntimeData = new DataLists(); RuntimeProperty = RuntimeData.GlobalProperties.First(); RuntimeIndex = new IndexViewModel(); RuntimePlane = new PlaneViewModel(); RuntimeMaxValues = new MaxValues(); }
public ActionResult AddPlane() { var planeModel = new PlaneViewModel { PlaneModels = PlaneRequests.GetPlaneModels() }; return(View(planeModel)); }
public int Update(PlaneViewModel model) { if (ModelState.IsValid) { var plane = _mapper.Map <Plane>(model); _repository.Update(plane); return(plane.Id); } return(0); }
public int Update(PlaneViewModel model) { if (ModelState.IsValid) { var airport = _mapper.Map <Airport>(model); _repository.Update(airport); return(airport.Id); } return(0); }
public ActionResult AddPlane(PlaneViewModel planeModel) { var isSuccess = PlaneRequests.AddPlane(planeModel); if (!isSuccess || !ModelState.IsValid) { return(View("AddPlane")); } return(RedirectToAction("CompanyPlanes", "Planes")); }
public IEnumerable <Plane> GetAvailablePlanes(PlaneViewModel planeView) { return(_context.AirDbContext.Planes .Where(x => x.PlaneModel.Capacity >= planeView.StartCountPlaces && x.PlaneModel.Capacity <= planeView.EndCountPlaces && x.Rents.All(p => p.Rent.IsCompleated)) .ToList() .Take(planeView.CountPlanes) .ToList()); }
public static bool AddPlane(PlaneViewModel plane) { try { ClientExtenctions.PostData(plane, string.Concat(PlaneUrl, "AddPlane")); return(true); } catch (Exception) { return(false); } }
public void AddPlane([FromBody] PlaneViewModel plane) { var planes = new List <Plane>(plane.CountPlanes); for (var i = 0; i < plane.CountPlanes; i++) { planes.Add(new Plane { CompanyId = plane.CompanyId, PlaneModelId = plane.PlaneModelId, CostPerFlight = plane.CostPerFlight }); } _context.AirDbContext.Planes.AddRange(planes); _context.AirDbContext.SaveChanges(); }
// Ctor - gets a ViewModel object as a parameter. public ControllerWindow(PlaneViewModel vm) { InitializeComponent(); _vm = vm; this.DataContext = this._vm; // set default values to sliders _throttle = ThrottleSlider.Value = 0.5; _aileron = AileronSlider.Value = 0; // subscribe to coords change _vm.PropertyChanged += UpdateCoordsPin; this.SetErrorEvent(); // add pushpin to map _pin.Location = new Location(vm.VM_Latitude, vm.VM_Longitude); _pin.ToolTip = "Airplane"; this.myMap.Children.Add(_pin); }
public ActionResult ReportPlanes() { var planes = this.msSqlData.Planes.GetAll(null); var planePassports = this.msSqlData.PlanePassports.GetAll(null); var manufacturers = this.msSqlData.Manufacturers.GetAll(null); var models = this.msSqlData.Models.GetAll(null); var result = new List <PlaneViewModel>(); foreach (var plane in planes) { var newPlane = new PlaneViewModel((Plane)plane); result.Add(newPlane); } var data = "PlanesDataSet"; var file = "PlanesReport.rdlc"; return(ReportGenerator(result, data, file)); }
public bool Validate(ref ModelStateDictionary state, PlaneViewModel myViewModel) { Plane myPlane = myViewModel.Current; if (string.IsNullOrEmpty(myPlane.Name)) { state.AddModelError("1", "Debe introducir un nombre"); } if (string.IsNullOrEmpty(myPlane.Description)) { state.AddModelError("2", "Debe introducir una descripcion"); } if (myViewModel.PostedFile == null || myViewModel.PostedFile.ContentLength == 0) { state.AddModelError("3", "Debe introducir un fichero válido"); } return(state.IsValid); }
public ActionResult Save(PlaneViewModel myModel) { try { _LoggingService.Write("PlaneController (Save) page access", true); var myModelState = ModelState; if (_PlaneRepository.Validate(ref myModelState, myModel)) { myModel.Current.FileContent = ReadAll(myModel.PostedFile); myModel.Current.Id = Guid.NewGuid().ToString(); _PlaneRepository.Save(myModel.Current); _LoggingService.Write("PlaneController - Save () successful: ", true); return(RedirectToAction("Index", "Home")); } return(View("New", myModel)); } catch (Exception ex) { _LoggingService.WriteWithInner(ex, true, "PlaneController(Save) error: "); return(new HttpNotFoundResult()); } }
public Aircrafts() { InitializeComponent(); DataContext = new PlaneViewModel(); }
private void InitializeViewModels() { WarehouseRootViewModel = new WarehouseRootViewModel(CMContext); foreach (var warehouse in CMContext.Warehouse.Local) { WarehouseViewModel bufferWarehouseViewModel = new WarehouseViewModel(CMContext); bufferWarehouseViewModel.Warehouse = warehouse; foreach (var plane in warehouse.Planes) { PlaneViewModel bufferPlaneViewModel = new PlaneViewModel(CMContext); bufferPlaneViewModel.Plane = plane; foreach (var block in plane.Blocks) { BlockViewModel bufferBlockViewModel = new BlockViewModel(CMContext); bufferBlockViewModel.Block = block; foreach (var cargoCollection in block.CargoCollections) { CargoCollectionViewModel bufferCargoCollectionViewModel = new CargoCollectionViewModel(CMContext) { CargoCollectionViewModels = CargoCollectionViewModels }; bufferCargoCollectionViewModel.CargoCollection = cargoCollection; bufferCargoCollectionViewModel.BlockViewModel = bufferBlockViewModel; bufferCargoCollectionViewModel.SelectedPurchasePrizeDic = bufferCargoCollectionViewModel.CargoCollection.PurchasePrizeDics[0]; bufferCargoCollectionViewModel.CargoCollectionViewModels = CargoCollectionViewModels; bufferBlockViewModel.CargoCollectionViewModels.Add(bufferCargoCollectionViewModel); CargoCollectionViewModels.Add(bufferCargoCollectionViewModel); } bufferBlockViewModel.PlaneViewModel = bufferPlaneViewModel; bufferPlaneViewModel.BlockViewModels.Add(bufferBlockViewModel); } bufferPlaneViewModel.WarehouseViewModel = bufferWarehouseViewModel; bufferWarehouseViewModel.PlaneViewModels.Add(bufferPlaneViewModel); } bufferWarehouseViewModel.WarehouseRootViewModel = WarehouseRootViewModel; WarehouseRootViewModel.WarehouseViewModels.Add(bufferWarehouseViewModel); } foreach (var cargo in CMContext.Cargo.Local) { CargoViewModel bufferCargoViewModel = new CargoViewModel(CMContext); bufferCargoViewModel.Cargo = cargo; bufferCargoViewModel.CargoViewModels = CargoViewModels; bufferCargoViewModel.CargoCollectionViewModels = CargoCollectionViewModels; CargoViewModels.Add(bufferCargoViewModel); } PurchaseOrderCollectionViewModels = new ObservableCollection <PurchaseOrderCollectionViewModel>(); foreach (var purchaseOrderCollection in CMContext.PurchaseOrderCollection.Local) { PurchaseOrderCollectionViewModel pocvm = new PurchaseOrderCollectionViewModel(CMContext) { PurchaseOrderCollection = purchaseOrderCollection, PurchaseOrderCollectionViewModels = PurchaseOrderCollectionViewModels }; foreach (var purchaseOrder in purchaseOrderCollection.PurchaseOrders) { PurchaseOrderViewModel povm = new PurchaseOrderViewModel(CMContext) { PurchaseOrder = purchaseOrder, PurchaseOrderCollectionViewModel = pocvm }; pocvm.PurchaseOrderViewModels.Add(povm); } PurchaseOrderCollectionViewModels.Add(pocvm); } SellOrderCollectionViewModels = new ObservableCollection <SellOrderCollectionViewModel>(); foreach (var sellOrderCollection in CMContext.SellOrderCollection.Local) { SellOrderCollectionViewModel socvm = new SellOrderCollectionViewModel(CMContext) { SellOrderCollection = sellOrderCollection, SellOrderCollectionViewModels = SellOrderCollectionViewModels }; foreach (var sellOrder in sellOrderCollection.SellOrders) { SellOrderViewModel sovm = new SellOrderViewModel(CMContext, new CargoCollectionViewModel()) { SellOrder = sellOrder }; socvm.SellOrderViewModels.Add(sovm); } SellOrderCollectionViewModels.Add(socvm); } }
public Connect(PlaneViewModel vm) { InitializeComponent(); this.vm = vm; }
public Planes() { this.InitializeComponent(); ViewModel = new PlaneViewModel(); }
public static List <Plane> GetAvailablePlanes(PlaneViewModel model) { return(ClientExtenctions.PostDataAndGetResult <PlaneViewModel, List <Plane> >(model, string.Concat(PlaneUrl, "GetAvailablePlanes"))); }