Exemplo n.º 1
0
        private static void geraBlocosDeTempo()
        {
            TimeSpan tempo         = new TimeSpan(9, 0, 0);
            TimeSpan tempoAnterior = new TimeSpan(9, 0, 0);
            var      dataInicial   = new DateTime(2020, 04, 16);

            for (var x = 0; x < 17; x++)
            {
                Agendamento agendamento = new Agendamento();
                agendamento.Horarios      = new List <Horario>();
                agendamento.DataCriacao   = DateTime.Now;
                agendamento.DataAlteracao = agendamento.DataCriacao;

                agendamento.Data = dataInicial.AddDays(x).ToShortDateString();

                for (int i = 0; i <= 23; i++)
                {
                    Horario horario = new Horario();
                    tempo = tempo.Add(new TimeSpan(0, 30, 0));

                    horario.Data  = agendamento.Data;
                    horario.Hora  = $"{tempoAnterior.Hours.ToString("00")}:{tempoAnterior.Minutes.ToString("00")} - {tempo.Hours.ToString("00")}:{tempo.Minutes.ToString("00")}";
                    horario.Vagas = 2;

                    Console.WriteLine(horario.Hora);

                    tempoAnterior = tempo;

                    horariodb.Create(horario);
                    agendamento.Horarios.Add(horario);
                }

                agendamentodb.Create(agendamento);
            }
        }
Exemplo n.º 2
0
        public ActionResult <Agendamento> Create(Agendamento agendamento)
        {
            agendamento.DataCriacao   = DateTime.Now;
            agendamento.DataAlteracao = agendamento.DataCriacao;

            _dbService.Create(agendamento);
            return(CreatedAtRoute("GetAgendamento", new { id = agendamento.Id.ToString() }, agendamento));
        }