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); }
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()); }
public void GivenTheUserCompleteTheRequirements() { ValidReservation = new CreateReservaViewModel { Fecha = "12 Marzo", Hora = "12:00", Observaciones = "Realizo el pago", VehiculoId = 1, LocalId = 1, ReservaEstadoId = 1, }; }