Example #1
0
        public PainelInicialQueryResult Handle()
        {
            try
            {
                using (var _context = new CafeDbContext())
                {
                    var garcons = new Dictionary <int, string>();
                    var mesas   = new Dictionary <int, int>();

                    garcons = _context.TbWaitstaff
                              .AsNoTracking()
                              .Where(i => i.TbTabOpened.Any())
                              .ToDictionary(d => d.Id, d => d.DsName);

                    mesas = _context.TbTabOpened
                            .AsNoTracking()
                            .Where(i => i.StActive)
                            .ToDictionary(d => d.Id, d => d.NuTable.Value);

                    return(new PainelInicialQueryResult(garcons, mesas));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        public IEnumerable <MesaAbertaQueryResult> Handle()
        {
            try
            {
                using (var _context = new CafeDbContext())
                {
                    var result = _context.TbTabOpened
                                 .Include(p => p.TbOrdered)
                                 .Include(g => g.IdWaiterNavigation)
                                 .AsNoTracking()
                                 .Where(e => e.StActive)
                                 .AsParallel()
                                 .Select(o => new MesaAbertaQueryResult(
                                             o.Id,
                                             o.NuTable.Value,
                                             new GarcomQueryResult(o.IdWaiterNavigation.Id, o.IdWaiterNavigation.DsName),
                                             null,
                                             o.DtService,
                                             o.StActive
                                             )).ToList();

                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #3
0
 public IEnumerable <MenuItemQueryResult> Handle()
 {
     try
     {
         using (var _context = new CafeDbContext())
         {
             return(_context.TbMenuItem
                    .AsNoTracking()
                    .Where(x => x.StActive)
                    .AsParallel()
                    .Select(x => new MenuItemQueryResult(
                                x.Id,
                                x.NuMenuItem,
                                x.DsDescription,
                                x.NuPrice,
                                x.StIsDrink,
                                x.StActive
                                )).ToList());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #4
0
 public bool Validacao(int numMesa)
 {
     using (var _context = new CafeDbContext())
     {
         return(!_context.TbTabOpened
                .Where(x => x.NuTable == numMesa)
                .Where(x => x.StActive).Any());
     }
 }
Example #5
0
        public GarcomTarefaQueryResult Handle(GarconsTarefasQuery query)
        {
            try
            {
                using (var _context = new CafeDbContext())
                {
                    var garcom = _context.TbWaitstaff
                                 .AsNoTracking()
                                 .Where(g => g.Id == query.Id)
                                 .Include(p => p.TbTabOpened)
                                 .ThenInclude(o => o.TbOrdered)
                                 .ThenInclude(o => o.TbOrderedItem)
                                 .ThenInclude(m => m.IdMenuItemNavigation)
                                 .AsParallel()
                                 .Select(g => new GarcomTarefaQueryResult(
                                             g.Id,
                                             g.DsName,
                                             g.TbTabOpened.Where(x => x.StActive).Select(m => new MesaAbertaQueryResult
                                                                                         (
                                                                                             m.Id,
                                                                                             m.NuTable.Value,
                                                                                             new GarcomQueryResult(m.IdWaiterNavigation.Id, m.IdWaiterNavigation.DsName),
                                                                                             m.TbOrdered.Where(x => x.TbOrderedItem.Any()).Select(p => new PedidoQueryResult(
                                                                                                                                                      p.Id,
                                                                                                                                                      p.TbOrderedItem.Where(x => !x.DtServed.HasValue).Select(i => new PedidoItemQueryResult(
                                                                                                                                                                                                                  i.Id,
                                                                                                                                                                                                                  new MenuItemQueryResult(
                                                                                                                                                                                                                      i.IdMenuItemNavigation.Id,
                                                                                                                                                                                                                      i.IdMenuItemNavigation.NuMenuItem,
                                                                                                                                                                                                                      i.IdMenuItemNavigation.DsDescription,
                                                                                                                                                                                                                      i.IdMenuItemNavigation.NuPrice,
                                                                                                                                                                                                                      i.IdMenuItemNavigation.StIsDrink,
                                                                                                                                                                                                                      i.IdMenuItemNavigation.StActive
                                                                                                                                                                                                                      ),
                                                                                                                                                                                                                  i.NuAmount,
                                                                                                                                                                                                                  i.DtToServe,
                                                                                                                                                                                                                  i.DtInPreparation,
                                                                                                                                                                                                                  i.DtServed,
                                                                                                                                                                                                                  i.DsDescription)
                                                                                                                                                                                                              )
                                                                                                                                                      )),
                                                                                             m.DtService,
                                                                                             m.StActive
                                                                                         ))
                                             )).FirstOrDefault();

                    return(garcom);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #6
0
        public MesaAbertaQueryResult Handle(MesaAbertaQuery query)
        {
            try
            {
                using (var _context = new CafeDbContext())
                {
                    var mesa = _context.TbTabOpened
                               .AsNoTracking()
                               .Where(e => ((query.Id > 0) && e.Id == query.Id) || ((query.NumMesa > 0) && e.NuTable == query.NumMesa))
                               .Where(e => e.StActive)
                               .Include(g => g.IdWaiterNavigation)
                               .Include(p => p.TbOrdered)
                               .ThenInclude(pi => pi.TbOrderedItem)
                               .ThenInclude(m => m.IdMenuItemNavigation)
                               .AsParallel()
                               .Select(o => new MesaAbertaQueryResult(
                                           o.Id,
                                           o.NuTable.Value,
                                           new GarcomQueryResult(o.IdWaiterNavigation.Id, o.IdWaiterNavigation.DsName),
                                           o.TbOrdered.Select(p => new PedidoQueryResult(
                                                                  p.Id,
                                                                  p.TbOrderedItem.Select(i => new PedidoItemQueryResult(
                                                                                             i.Id,
                                                                                             new MenuItemQueryResult(
                                                                                                 i.IdMenuItemNavigation.Id,
                                                                                                 i.IdMenuItemNavigation.NuMenuItem,
                                                                                                 i.IdMenuItemNavigation.DsDescription,
                                                                                                 i.IdMenuItemNavigation.NuPrice,
                                                                                                 i.IdMenuItemNavigation.StIsDrink,
                                                                                                 i.IdMenuItemNavigation.StActive),
                                                                                             i.NuAmount,
                                                                                             i.DtToServe,
                                                                                             i.DtInPreparation,
                                                                                             i.DtServed
                                                                                             )))),
                                           o.DtService,
                                           o.StActive
                                           )).FirstOrDefault();

                    return(mesa);
                }
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Example #7
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, CafeDbContext context)
        {
            app.UseDefaultFiles();
            app.UseStaticFiles();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            context.Database.EnsureCreated();
            app.UseMvc();

            app.UseOpenApi();
            app.UseSwaggerUi3();
        }
Example #8
0
        public IEnumerable <CozinhaTarefasQueryResult> Handle(CozinhaTarefasQuery query)
        {
            try
            {
                using (var _context = new CafeDbContext())
                {
                    var result = _context.TbOrderedItem
                                 .AsNoTracking()
                                 .Include(i => i.IdMenuItemNavigation)
                                 .Include(i => i.IdOrderedNavigation)
                                 .Include(i => i.IdOrderedNavigation.IdTabOpenedNavigation)
                                 .Where(x => !x.IdMenuItemNavigation.StIsDrink)
                                 .Where(x => x.DtInPreparation.HasValue)
                                 .AsParallel()
                                 .Select(o => new CozinhaTarefasQueryResult(
                                             o.IdOrderedNavigation.IdTabOpenedNavigation.Id,
                                             o.IdOrderedNavigation.Id,
                                             o.Id,
                                             new MenuItemQueryResult(
                                                 o.IdMenuItemNavigation.Id,
                                                 o.IdMenuItemNavigation.NuMenuItem,
                                                 o.IdMenuItemNavigation.DsDescription,
                                                 o.IdMenuItemNavigation.NuPrice,
                                                 o.IdMenuItemNavigation.StIsDrink,
                                                 o.IdMenuItemNavigation.StActive
                                                 ),
                                             o.NuAmount,
                                             o.DtToServe,
                                             o.DtInPreparation,
                                             o.DtServed,
                                             o.DsDescription
                                             )).ToList();

                    return(result.OrderBy(x => x.PedidoId));
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
Example #9
0
 public IEnumerable <GarcomQueryResult> Handle()
 {
     try
     {
         using (var context = new CafeDbContext())
         {
             var result = context.TbWaitstaff
                          .AsNoTracking()
                          .AsParallel()
                          .Select(e => new GarcomQueryResult(
                                      e.Id,
                                      e.DsName))
                          .ToList();
             return(result);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #10
0
        public AbrirNovaMesaCommandResult Handle(AbrirNovaMesaCommand c)
        {
            try
            {
                using (var _context = new CafeDbContext())
                {
                    if (Validacao(c.NumMesa))
                    {
                        var table = new TbTabOpened
                        {
                            NuTable            = c.NumMesa,
                            IdWaiter           = c.GarcomId,
                            StActive           = c.Ativo,
                            DtService          = c.DataServico,
                            StUniqueIdentifier = Guid.NewGuid()
                        };

                        _context.TbTabOpened.Add(table);
                        var id = _context.SaveChanges();

                        return(_context.TbTabOpened
                               .AsNoTracking()
                               .AsParallel()
                               .Where(x => x.Id == table.Id)
                               .Select(o => new AbrirNovaMesaCommandResult(o.Id, o.NuTable.Value, o.IdWaiter.Value, o.StActive, o.DtService.Value))
                               .FirstOrDefault());
                    }
                    else
                    {
                        throw new Exception("Essa mesa já está aberta");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #11
0
 public CategoryDataManager(CafeDbContext context)
 {
     this._context = context;
 }
 public CafeService(CafeDbContext cafeDbContext)
 {
     _cafeDbContext = cafeDbContext;
 }
Example #13
0
 public SaleDataManager(CafeDbContext context)
 {
     this._context = context;
 }
 public ProductDataManager(CafeDbContext context)
 {
     this._context = context;
 }
Example #15
0
 public ClientDataManager(CafeDbContext context)
 {
     this._context = context;
 }
Example #16
0
 public MenusController(CafeDbContext cafeDbContext)
 {
     _cafeDbContext = cafeDbContext;
 }
Example #17
0
 public ReservationsController(CafeDbContext cafeDbContext)
 {
     _cafeDbContext = cafeDbContext;
 }
Example #18
0
 public UserDao()
 {
     db = new CafeDbContext();//Khởi tạo db
 }