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)); } }
// GET: RaspberryController/Create public ActionResult Create() { var viewModel = new RaspberryCreateViewModel(); return(View(viewModel)); }