public Task <ControleViewModel> GiveBack(DevolucaoViewModel vm) { var controle = _context.Controles.Find(vm.Codigo); controle.FuncionarioDevolucao = _context.Funcionarios.Find(vm.FuncionarioID); controle.UsuarioDevolucao = CurrentUser; controle.Devolucao = vm.Data; _context.Controles.Update(controle); _context.SaveChanges(); return(Task.FromResult(_mapper.Map <ControleViewModel>(controle))); }
public async Task <IActionResult> Devolver(DevolucaoViewModel vm) { try { var result = await _controleService.GiveBack(vm); return(Ok(result)); } catch (Exception e) { return(BadRequest(e.Message)); } }