public HangarPage() { InitializeComponent(); BindingContext = new AddShipViewModel(); //var _container = BindingContext as AddShipViewModel; //myHangarList.ItemsSource = _container.Items.Where(i => i.IsVisible == true); }
public ActionResult AddShip() { AddShipViewModel asvm = new AddShipViewModel { Location = _context.Location .DistinctBy(l => l.Origin) .ToList() }; return(View(asvm)); }
public ActionResult CreateShip(ShipDetails shipDetails) { AddShipViewModel asvm = new AddShipViewModel { Location = _context.Location .DistinctBy(l => l.Origin) .ToList() }; if (!ModelState.IsValid) { ViewBag.IsSuccess = false; ViewBag.Message = "Ship Create Failed."; return(View("AddShip", asvm)); } shipDetails.RemainingBaySize = shipDetails.BaySize; shipDetails.Availability = true; _context.ShipDetails.Add(shipDetails); try { _context.SaveChanges(); ViewBag.IsSuccess = true; ViewBag.Message = "Ship added successfully. Thanks for using our service"; ModelState.Clear(); } catch (Exception ex) { ViewBag.IsSuccess = false; ViewBag.Message = "Error in adding ship! \nError: " + ex.Message; } return(View("AddShip", asvm)); }
public AddShipPage() { InitializeComponent(); BindingContext = new AddShipViewModel(); }