示例#1
0
        public async Task MakeaReservation()
        {
            //Arrange


            var BDName  = Guid.NewGuid().ToString();
            var context = BuildContext(BDName);


            //Act

            var newreservation = new CreateReservaViewModel()
            {
                Fecha           = "12/03/20",
                Hora            = "12:00",
                Observaciones   = "Color azul",
                VehiculoId      = 1,
                LocalId         = 1,
                ReservaEstadoId = 1,
            };

            var controller = new ReservasController(context);

            var response = await controller.Create(newreservation);

            var reservation = response.Result as StatusCodeResult;

            //Assert

            Assert.IsInstanceOf <OkResult>(reservation);
        }
示例#2
0
        public async Task <ActionResult <Reserva> > Create([FromBody] CreateReservaViewModel model)//CAMBIAR
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Reserva r = new Reserva//CAMBIAR
            {
                Fecha           = model.Fecha,
                Hora            = model.Hora,
                Observaciones   = model.Observaciones,
                VehiculoId      = model.VehiculoId,
                LocalId         = model.LocalId,
                ReservaEstadoId = model.ReservaEstadoId,
            };

            _context.Reservas.Add(r);//CAMBIAR

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (Exception)
            {
                return(BadRequest());
            }

            return(Ok());
        }
示例#3
0
 public void GivenTheUserCompleteTheRequirements()
 {
     ValidReservation = new CreateReservaViewModel
     {
         Fecha           = "12 Marzo",
         Hora            = "12:00",
         Observaciones   = "Realizo el pago",
         VehiculoId      = 1,
         LocalId         = 1,
         ReservaEstadoId = 1,
     };
 }