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());
            }
        }
Ejemplo n.º 2
0
        public async Task <bool> GetSalaAgendada([FromBody()] AgendaSalaDTO agendaSalaDTO)
        {
            var agendado = Ok(await _agendaSalaManager.GetVerificaAgendamento(_mapper.Map <AgendaSalaModel>(agendaSalaDTO)));

            if (agendado.StatusCode >= 400 || (bool)agendado.Value == false)
            {
                return(false);
            }
            return(true);
        }