Beispiel #1
0
        public ActionResult Create(RaspberryCreateViewModel newModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("Create", newModel));
            }

            try
            {
                var newEntity = new Raspberry();
                newEntity.Name        = newModel.Name;
                newEntity.location    = newModel.Location;
                newEntity.IPadress    = newModel.IPadress;
                newEntity.RaspberryId = Guid.NewGuid();
                _context.Raspberrys.Add(newEntity);
                _context.SaveChanges();
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View("Create", newModel));
            }
        }
Beispiel #2
0
        // GET: RaspberryController/Create
        public ActionResult Create()
        {
            var viewModel = new RaspberryCreateViewModel();

            return(View(viewModel));
        }