// public async Task<IActionResult> Create([Bind("Id,Name,ToolName,MacAddress,Location,Time")] Tool tool) public async Task <IActionResult> Create(Tool tool) { if (ModelState.IsValid) { tool = Trim(tool); if (MacExists(tool.MacAddress) == true) { ModelState.AddModelError(string.Empty, "Narzędzie o takim adresie MAC już istnieje"); return(View(tool)); } else { _context.Add(tool); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } return(View(tool)); }
public async Task <IActionResult> Create(Hub hub) { if (ModelState.IsValid) { hub = Trim(hub); if (IpExists(hub.IpAddress) == true) { ModelState.AddModelError(string.Empty, "Koncentrator o takim adresie IP już istnieje"); return(View(hub)); } else { _context.Add(hub); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } return(View(hub)); }