public async Task <IActionResult> Post([FromForm] AgendaSalaViewModel agendaSalaViewModel) { try { var verificaSalaAgendada = _agendaSalaManager.GetVerificaAgendamento(_mapper.Map <AgendaSalaModel>(agendaSalaViewModel)); if (agendaSalaViewModel.AgendamentoFinal < agendaSalaViewModel.AgendamentoInicial) { ViewBag.message = "Data Inicial maior que data final"; ViewBag.Combo = _mapper.Map <IList <SalaCadastroViewModel> >(await _salaManager.GetSalas()); return(View()); } if (verificaSalaAgendada.Result == true) { ViewBag.message = "Sala ja agendada nesse periodo"; ViewBag.Combo = _mapper.Map <IList <SalaCadastroViewModel> >(await _salaManager.GetSalas()); return(View()); } else { await _agendaSalaManager.Insert(_mapper.Map <AgendaSalaModel>(agendaSalaViewModel)); return(RedirectToAction("Index", "Agendamento")); } } catch (Exception ex) { TempData["NotifyMessage"] = "" + ex.Message; return(BadRequest()); } }
public async Task <IActionResult> Post([FromBody()] AgendaSalaDTO agendaSalaDTO) { return(Ok(await _agendaSalaManager.Insert(_mapper.Map <AgendaSalaModel>(agendaSalaDTO)))); }