public async Task <IActionResult> Edit([FromRoute] int id, [FromForm] MachineEditViewModel machine) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != machine.Id) { return(BadRequest()); } try { await _machineService.UpdateAsync(_mapper.Map <Machine>(machine)); } catch (DbUpdateConcurrencyException) { if (!MachineExists(id)) { return(NotFound()); } throw; } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create([FromForm] MachineEditViewModel machine) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _machineService.CreateAsync(_mapper.Map <Machine>(machine)); return(RedirectToAction(nameof(Index))); }