public ActionResult <ReservaViewModel> Post(ReservaInputModel reservaInput) { Reserva reserva = MapearReserva(reservaInput); var response = _reservaService.Guardar(reserva); if (response.Error) { ModelState .AddModelError("Error al guardar la Reserva", response.Mensaje); var detallesproblemas = new ValidationProblemDetails(ModelState); detallesproblemas.Status = StatusCodes.Status500InternalServerError; return(BadRequest(detallesproblemas)); } return(Ok(response.Reserva)); }
public ActionResult <ReservaViewModel> Post(ReservaInputModel reservaInput) { Reserva reserva = MapearReserva(reservaInput); var response = _reservaService.Guardar(reserva); if (response.Error) { ModelState.AddModelError("Guardar reserva", response.Mensaje); var problemDetails = new ValidationProblemDetails(ModelState) { Status = StatusCodes.Status400BadRequest, }; return(BadRequest(problemDetails)); } return(Ok(response.Reserva)); }
protected void btnCrearReserva_Click(object sender, EventArgs e) { ValidarSesion(); Page.Validate("ValidacionReserva"); if (!Page.IsValid) { upModalReserva.Update(); return; } try { Reserva reserva = new Reserva(); reserva.FechaReserva = Convert.ToDateTime(txtFechaHoraReserva.Text); reserva.CantidadComensales = int.Parse(txtCantidadComensalesReserva.Text); reserva.IdEstadoReserva = int.Parse(ddlEstadoReserva.SelectedValue); reserva.IdCliente = int.Parse(ddlClienteReserva.SelectedValue); reserva.IdMesa = int.Parse(ddlMesaReserva.SelectedValue); Token token = (Token)Session["token"]; _reservaService = new ReservaService(token.access_token); int idReserva = _reservaService.Guardar(reserva); if (idReserva != 0) { List <Reserva> reservas = _reservaService.Obtener(); if (reservas != null && reservas.Count > 0) { var reservasOrdenadas = reservas.OrderByDescending(x => x.FechaReserva).ToList(); actualizarRepeater(listaReservas, reservasOrdenadas, listaReservasVacia); upListaReservas.Update(); } ScriptManager.RegisterStartupScript(Page, Page.GetType(), "crearReserva", "Swal.fire('Reserva creada', '', 'success');", true); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "modalReserva", "$('#modalReserva').modal('hide');", true); } else { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "modalReserva", "Swal.fire('Error al crear reserva', '', 'error');", true); } } catch (Exception ex) { string mensaje = ex != null && ex.Message != null ? ex.Message : "Ocurrió un error inesperado. Intente nuevamente"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "error", "Swal.fire('Error', '" + mensaje + "', 'error');", true); return; } }
public async Task <ActionResult <ReservaViewModel> > Post(ReservaInputModel reservaInput) { Reserva reserva = MapearReserva(reservaInput); var response = _reservaService.Guardar(reserva); if (response.Error) { ModelState .AddModelError("Error al guardar la Reserva", response.Mensaje); var detallesproblemas = new ValidationProblemDetails(ModelState); detallesproblemas.Status = StatusCodes.Status500InternalServerError; return(BadRequest(detallesproblemas)); } var reservaview = new ReservaViewModel(response.Reserva); await _hubContext.Clients.All.SendAsync("reservaRegistrada", reservaview); return(Ok(reservaview)); }
protected int guardarReserva(int idCliente, int idMesa, DateTime fecha) { Reserva reserva = new Reserva(); reserva.FechaReserva = fecha; reserva.CantidadComensales = int.Parse(txtComensales.Text); reserva.IdEstadoReserva = EstadoReserva.creada; reserva.IdCliente = idCliente; reserva.IdMesa = idMesa; Token token = (Token)Session["token"]; _reservaService = new ReservaService(token.access_token); int idReserva = _reservaService.Guardar(reserva); reserva.Id = idReserva; Session["reservaCreada"] = reserva; return(idReserva); }
public async Task <ActionResult <ReservaViewModel> > post(ReservaInputModel reservaInput) { Reserva reserva = MapearReserva(reservaInput); var response = _reservaservice.Guardar(reserva); if (response.Error) { ModelState.AddModelError("Guardar Reserva", response.Mensaje); var problemDetails = new ValidationProblemDetails(ModelState) { Status = StatusCodes.Status400BadRequest, }; return(BadRequest(problemDetails)); } var reservaViewModel = new ReservaViewModel(response.Reserva); await _hubContext.Clients.All.SendAsync("reservaRegistrada", reservaViewModel); return(Ok(reservaViewModel)); }