Example #1
0
 public HangarPage()
 {
     InitializeComponent();
     BindingContext = new AddShipViewModel();
     //var _container = BindingContext as AddShipViewModel;
     //myHangarList.ItemsSource = _container.Items.Where(i => i.IsVisible == true);
 }
Example #2
0
        public ActionResult AddShip()
        {
            AddShipViewModel asvm = new AddShipViewModel
            {
                Location = _context.Location
                           .DistinctBy(l => l.Origin)
                           .ToList()
            };

            return(View(asvm));
        }
Example #3
0
        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));
        }
Example #4
0
 public AddShipPage()
 {
     InitializeComponent();
     BindingContext = new AddShipViewModel();
 }