예제 #1
0
        //create
        //test
        public bool CreateLaunchSite(LaunchSiteCreate model)
        {
            LaunchSite entity = new LaunchSite
            {
                Name       = model.Name,
                Location   = model.Location,
                CreatedUtc = DateTimeOffset.Now
            };

            _context.LaunchSites.Add(entity);
            return(_context.SaveChanges() == 1);
        }
예제 #2
0
        public ActionResult Create(LaunchSiteCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = new LaunchSiteService();

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