Esempio n. 1
0
        //create
        //test
        public bool CreateSpaceStation(SpaceStationCreate model)
        {
            SpaceStation entity = new SpaceStation
            {
                Name             = model.Name,
                MaximumOccupancy = model.MaximumOccupancy,
                CreatedUtc       = DateTimeOffset.Now
            };

            _context.SpaceStations.Add(entity);
            return(_context.SaveChanges() == 1);
        }
        public ActionResult Create(SpaceStationCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = new SpaceStationService();

            if (service.CreateSpaceStation(model))
            {
                TempData["SaveResult"] = "Your Space Station was created.";
                return(RedirectToAction("Index"));
            }
            ;
            ModelState.AddModelError("", "Space Station could not be created.");
            return(View(model));
        }