Ejemplo n.º 1
0
        public ResponseGetComandaById GetById(string comandaId)
        {
            ResponseGetComandaById comandaById = _query.GetById(comandaId);

            if (comandaById == null)
            {
                NullReferenceException exception = new NullReferenceException("Comanda con id " + comandaId + " no encontrada");
                throw exception;
            }
            else
            {
                return(comandaById);
            }
        }
Ejemplo n.º 2
0
        public List <ResponseGetComandaById> GetAllComanda(string fecha)
        {
            List <ResponseGetComandaById> allComandaDtos = new List <ResponseGetComandaById>();
            var db = new QueryFactory(connection, sqlKataCompiler);

            var query = db.Query("Comandas")
                        .Select("Comandas.ComandaId",
                                "Comandas.PrecioTotal",
                                "Comandas.Fecha",
                                "FormaEntrega.Descripcion AS FormaEntrega")
                        .Join("FormaEntrega", "FormaEntrega.FormaEntregaId", "Comandas.FormaEntregaId")
                        .When(!string.IsNullOrWhiteSpace(fecha), q => q.WhereLike("Comandas.Fecha", $"%{fecha}%"));

            var allComandas = query.Get <ResponseGetAllComandaDto>().ToList();

            foreach (var comanda in allComandas)
            {
                ResponseGetComandaById comandaById = GetById(comanda.ComandaId.ToString());
                allComandaDtos.Add(comandaById);
            }

            return(allComandaDtos);
        }