public GetDeliveryRequestHandler(DeliveryDbContext dbContext, IMapper mapper,
                                  ILogger <NewDeliveryRequestHandler> logger)
 {
     _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
     _mapper    = mapper ?? throw new ArgumentNullException(nameof(mapper));
     _logger    = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Exemple #2
0
 public UpdateService(DeliveryDbContext context, IHubContext <DispatchHub, IDispatchHubClient> dispatchHubContext, IHubContext <RestaurantsHub, IRestaurantsHubClient> restaurantsHubContext, IHubContext <UserHub, IUserHubClient> userHubContext)
 {
     _context               = context;
     _dispatchHubContext    = dispatchHubContext;
     _restaurantsHubContext = restaurantsHubContext;
     _userHubContext        = userHubContext;
 }
Exemple #3
0
 public ChangeDeliveryStateRequestHandler(DeliveryDbContext dbContext,
                                          IStateRuleEngine stateRuleEngine,
                                          ILogger <ChangeDeliveryStateRequestHandler> logger)
 {
     _dbContext       = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
     _stateRuleEngine = stateRuleEngine ?? throw new ArgumentNullException(nameof(stateRuleEngine));
     _logger          = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Exemple #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.



        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DeliveryDbContext deliveryDbContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseResponseCompression();
            deliveryDbContext.Database.EnsureCreated();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Exemple #5
0
 public DispatchHub(DeliveryDbContext context, UpdateService updateService)
 {
     _context       = context;
     _updateService = updateService;
 }
Exemple #6
0
 public DeleteDeliveryRequestHandler(DeliveryDbContext dbContext,
                                     ILogger <DeleteDeliveryRequestHandler> logger)
 {
     _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
     _logger    = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Exemple #7
0
 public RestaurantsController(DeliveryDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Exemple #8
0
 public DishesHub(DeliveryDbContext context)
 {
     _context = context;
 }
Exemple #9
0
 public ShoppingCartItemsController(DeliveryDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Exemple #10
0
 public DeliveryRepo(DeliveryDbContext _db)
 {
     this.db = _db;
 }
 public AccountsController(DeliveryDbContext dbContext, IConfiguration configuration)
 {
     _configuration = configuration;
     _auth          = new AuthService(_configuration);
     _dbContext     = dbContext;
 }
Exemple #12
0
 public RestaurantsHub(DeliveryDbContext context)
 {
     _context = context;
 }
Exemple #13
0
 public CategoriesController(DeliveryDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Exemple #14
0
 public UserHub(DeliveryDbContext context, UpdateService updateService)
 {
     _context       = context;
     _updateService = updateService;
 }
        public LocalReport GetDelivaryReport(
            String Receipt)
        {
            string receipt = Receipt;

            int                 type                = 2;
            int                 entryStatus         = 0;
            int                 transactionStatus   = 0;
            int                 defaultAddressType  = 0;
            Transaction         TransactionHeader   = new Transaction();
            TransactionCustomer TransactionCustomer = new TransactionCustomer();
            TransactionLines    TransactionLines    = new TransactionLines(null);

            using (var db = new DeliveryDbContext(builder.ConnectionString))
            {
                var transaction = from tra_h in db.RBOTRANSACTIONTABLE
                                  join sto in db.RBOSTORETABLE on tra_h.STORE equals sto.STOREID
                                  where tra_h.RECEIPTID == receipt &&
                                  tra_h.TYPE == type &&
                                  tra_h.ENTRYSTATUS == entryStatus
                                  select new Transaction()
                {
                    ReceiptID = tra_h.RECEIPTID,
                    StoreID   = sto.STOREID,
                    Name      = sto.NAME,
                    TransDate = tra_h.TRANSDATE ?? DateTime.MinValue,
                    NetAmount = tra_h.NETAMOUNT ?? 0
                };
                //  LINENUM   changed to LINENUM = (decimal)tra_i.LINEID  in line 195 colu 156 by rafeeq
                var transactionLine = from tra_h in db.RBOTRANSACTIONTABLE
                                      join tra_l in db.RBOTRANSACTIONSALESTRANS
                                      on tra_h.TRANSACTIONID equals tra_l.TRANSACTIONID
                                      join tra_i in db.RBOTRANSACTIONINFOCODETRANS
                                      on
                                      new { tra_l.TRANSACTIONID, tra_l.LINENUM, INFOCODEID = Program.isDelevary } equals new { tra_i.TRANSACTIONID, LINENUM = (decimal)tra_i.LINEID, tra_i.INFOCODEID } into info_d
                from info in info_d.DefaultIfEmpty()
                join info_sub in db.RBOINFORMATIONSUBCODETABLE on
                    info.INFORMATION equals info_sub.SUBCODEID into info_sub_d
                from info_s in info_sub_d.DefaultIfEmpty()
                where tra_h.RECEIPTID == receipt &&
                tra_h.TYPE == type &&
                tra_h.ENTRYSTATUS == entryStatus &&
                tra_l.TRANSACTIONSTATUS == transactionStatus
                    select new TransactionLine()
                {
                    ItemId         = tra_l.ITEMID,
                    Description    = tra_l.DESCRIPTION,
                    Qty            = (tra_l.QTY ?? 0) * -1,
                    TaxInckInPrice = tra_l.TAXINCLINPRICE ?? 0,
                    Comment        = tra_l.COMMENT,
                    ExtraInfo      = string.IsNullOrEmpty(info_s.DESCRIPTION) ? "NON DELIVERABLE" : info_s.DESCRIPTION
                };

                var transactionCustomer = from tra_h in db.RBOTRANSACTIONTABLE
                                          join tra_i in db.RBOTRANSACTIONINFOCODETRANS
                                          on
                                          new { tra_h.TRANSACTIONID, INFOCODEID = Program.customerInfoCode } equals new { tra_i.TRANSACTIONID, tra_i.INFOCODEID } into info_d
                from info in info_d.DefaultIfEmpty()
                join cust in db.CUSTTABLE on new { CUSTACCOUNT = string.IsNullOrEmpty(info.INFORMATION) ? tra_h.CUSTACCOUNT : info.INFORMATION } equals
                new { CUSTACCOUNT = cust.ACCOUNTNUM }
                join address in db.CUSTOMERADDRESS on
                new { cust.ACCOUNTNUM, ADDRESSTYPE = defaultAddressType } equals new { address.ACCOUNTNUM, address.ADDRESSTYPE }
                where tra_h.RECEIPTID == receipt &&
                tra_h.TYPE == type &&
                tra_h.ENTRYSTATUS == entryStatus
                select new TransactionCustomer()
                {
                    ReceiptID   = tra_h.RECEIPTID,
                    CustAccount = string.IsNullOrEmpty(info.INFORMATION) ? tra_h.CUSTACCOUNT : info.INFORMATION,
                    Name        = cust.NAME,
                    Address     = cust.ADDRESS,
                    Phone       = cust.PHONE,
                    Address1    = address.ADDRESS,
                    Street      = address.STREET
                };

                TransactionHeader = transaction.Count() > 0 ? transaction.ToList()[0] : null;

                TransactionLines = transactionLine.Count() > 0 ? new TransactionLines(transactionLine.ToList()) : null;

                TransactionCustomer = transactionCustomer.Count() > 0 ? transactionCustomer.ToList()[0] : null;

                //this.dataGridViewReceipt.DataSource = transaction.ToList();
                //this.dataGridViewTransaction.DataSource = transactionLine.ToList();
                //this.dataGridViewCustomer.DataSource = transactionCustomer.ToList();

                this.TransactionBindingSource.DataSource = TransactionHeader;

                this.TransactionCustomerBindingSource.DataSource = TransactionCustomer;

                this.TransactionLinesBindingSource.DataSource = TransactionLines;

                //ReportDataSource dataSourceTran = new ReportDataSource("Transaction", transaction.Count() > 0 ? transaction.ToList()[0] : null);
                //ReportDataSource dataSourceCust = new ReportDataSource("TrransactionCustomer", transactionCustomer.Count() > 0 ? transactionCustomer.ToList()[0] : null);
                //ReportDataSource dataSourceLine = new ReportDataSource("TransactionLines", transactionLine.Count() > 0 ? new TransactionLines(transactionLine.ToList()) : null);

                //this.reportViewerDelivary.LocalReport.DataSources.Add(dataSourceTran);
                //Sthis.reportViewerDelivary.LocalReport.DataSources.Add(dataSourceCust);
                //this.reportViewerDelivary.LocalReport.DataSources.Add(dataSourceLine);
                LocalReport.Refresh();
                return(LocalReport);
            }
        }
Exemple #16
0
 public ProductsController(DeliveryDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Exemple #17
0
        public static void Initialize(DbContextOptions <DeliveryDbContext> options)
        {
            using (var context = new DeliveryDbContext(options))
            {
                context.Database.EnsureCreated();

                if (context.Restaurants.Any())
                {
                    return;
                }

                var restaurants = DataSource.Data
                                  .Select((r, i) =>
                {
                    r.Id = i + 1;
                    return(r);
                })
                                  .ToList();

                var tags = restaurants
                           .SelectMany(r => r.Tags)
                           .Distinct()
                           .Select((t, i) => new Tag {
                    Id = i + 1, Name = t
                })
                           .ToList();

                var restaurantTags = restaurants
                                     .SelectMany(r => r.Tags.Select(t => new RestaurantTag
                {
                    RestaurantId = r.Id,
                    TagId        = tags.Single(tag => tag.Name == t).Id
                }))
                                     .ToList();

                var dishes = restaurants.SelectMany(r => r.Dishes.Select(d => new Dish
                {
                    Name         = d.Name,
                    Description  = d.Description,
                    Price        = d.Price,
                    RestaurantId = r.Id
                }))
                             .Select((d, i) =>
                {
                    d.Id = i + 1;
                    return(d);
                })
                             .ToList();

                var random = new Random();
                var orders = restaurants
                             .SelectMany(restaurant =>
                {
                    var currentTime     = DateTime.Now;
                    var completedOrders = Enumerable
                                          .Repeat(0, random.Next(100))
                                          .Select(_ =>
                    {
                        var orderedAt = currentTime.AddDays(random.NextDouble() * -60);
                        return(new Order
                        {
                            Username = GetRandomUsername(),
                            OrderedAt = orderedAt.Truncate(),
                            CompletedAt = orderedAt.AddMinutes(random.NextDouble() * 30).Truncate(),
                            RestaurantId = restaurant.Id,
                        });
                    });

                    var pendingOrders = Enumerable
                                        .Repeat(0, random.Next(3))
                                        .Select(_ => new Order
                    {
                        Username     = GetRandomUsername(),
                        OrderedAt    = currentTime.AddMinutes(-random.Next(31)).Truncate(),
                        CompletedAt  = null,
                        RestaurantId = restaurant.Id,
                    });
                    return(completedOrders.Concat(pendingOrders));
                })
                             .Select((o, i) =>
                {
                    o.Id = i + 1;
                    return(o);
                })
                             .ToList();

                var ratings = orders
                              .Where(o => o.CompletedAt != null && random.Next(5) == 0)
                              .Select(o =>
                {
                    var currentTime = DateTime.Now;
                    return(new Rating
                    {
                        Username = GetRandomUsername(),
                        CreatedAt = o.CompletedAt.Value.AddHours(random.NextDouble() * 24).Truncate(),
                        Score = (byte)random.Next(6),
                        RestaurantId = o.RestaurantId,
                        OrderId = o.Id
                    });
                })
                              .Select((r, i) =>
                {
                    r.Id = i + 1;
                    return(r);
                })
                              .ToList();

                context.Restaurants.AddRange(restaurants.Select(ri => new Restaurant {
                    Id = ri.Id, Name = ri.Name, Distance = ri.Distance
                }));
                context.Tags.AddRange(tags);
                context.RestaurantTags.AddRange(restaurantTags);
                context.Dishes.AddRange(dishes);
                context.Orders.AddRange(orders);
                context.Ratings.AddRange(ratings);
                context.SaveChanges();
            }
        }
 public OrdersController(DeliveryDbContext dbContext)
 {
     _dbContext = dbContext;
 }