public async Task <IActionResult> Edit(Guid id, AgendamentoViewModel agendamentoViewModel) { if (id != agendamentoViewModel.Id) { return(NotFound()); } var agendamentoAtualizacao = await ObterAgendamento(id); if (!ModelState.IsValid) { return(View(agendamentoViewModel)); } agendamentoAtualizacao.InicioAtendimento = agendamentoViewModel.InicioAtendimento; agendamentoAtualizacao.FimAtendimento = agendamentoViewModel.FimAtendimento; agendamentoAtualizacao.Observacao = agendamentoViewModel.Observacao; await _agendamentoService.Atualizar(_mapper.Map <Agendamento>(agendamentoAtualizacao)); if (!OperacaoValida()) { return(View(agendamentoAtualizacao)); } return(RedirectToAction("Index")); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,Realizado")] AgendamentoViewModel agendamentoViewModel) { if (id != agendamentoViewModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { var agendamento = _mapper.Map <Agendamento>(agendamentoViewModel); await _agendamentoService.Atualizar(agendamento); } catch (DbUpdateConcurrencyException) { if (!await AgendamentoViewModelExists(agendamentoViewModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(agendamentoViewModel)); }
public async Task <IActionResult> PutAgendamentos(int id, Agendamentos agendamentos) { try { agendamentos.AgendamentoId = id; _agendamentoService.Atualizar(agendamentos); return(Ok()); } catch (DbUpdateConcurrencyException) { if (await _agendamentoService.BuscarPorId(id) != null) { return(NotFound()); } else { throw; } } }
public void Atualizar(CadastroViewModel cadastroViewModel) { var agendamento = mapper.Map <Agendamento>(cadastroViewModel); agendamentoService.Atualizar(agendamento); }