Пример #1
0
        public async Task <ActionResult> CancelarTicket([FromBody] CerrarTicket ct)
        {
            var response = new ResponseBase();

            try
            {
                response = await this.ventas.CancelarTicket(ct);
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }
            return(Ok(response));
        }
        public async Task <ResponseBase> CerrarTicket(CerrarTicket ct)
        {
            var response = new ResponseBase();

            try
            {
                using (var connection = new SqlConnection(con.getConnection()))
                {
                    using (var command = new SqlCommand("Reporte.spCerrarTicket", connection))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Clear();
                        command.Parameters.AddWithValue("@idTicket", ct.idTicket);
                        command.Parameters.AddWithValue("@horaSalida", ct.horaSalida);
                        command.Parameters.AddWithValue("@total", ct.total);
                        command.Parameters.AddWithValue("@descripcion", ct.descripcion);
                        command.Parameters.AddWithValue("@comentario", ct.comentario);
                        command.Parameters.AddWithValue("@pago", ct.pago);
                        command.Parameters.AddWithValue("@cambio", ct.cambio);
                        command.Parameters.AddWithValue("@idMesa", ct.idMesa);
                        command.Parameters.AddWithValue("@fechaSalida", ct.fechaSalida);

                        connection.Open();
                        var result = await command.ExecuteNonQueryAsync();

                        if (result > 2)
                        {
                            response.success = true;
                            response.message = "Ticket Cerrado Correctamente";
                            response.id      = ct.idTicket;
                        }
                        else
                        {
                            response.success = false;
                            response.message = "Error";
                            response.id      = ct.idTicket;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }
            return(response);
        }