예제 #1
0
    public void RecreateDataBase()
    {
        var dataService = new SqLiteService("Database.db");

        dataService.CreateDB();
        FillDB(dataService);
    }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainPresenter"/>
        /// </summary>
        /// <param name="view">view</param>
        /// <param name="business">business logic</param>
        /// <param name="service">service message</param>

        public MainPresenter(IView view, BusinessModel business, IMessageService service)
        {
            this.view            = view;
            this.business        = business;
            this.messageService  = service;
            this.dataBaseService = new SqLiteService();

            this.business.LoaderImages.SearchResultCount = 5;
            this.view.StartSearchAudio       += this.View_StartSearch;
            this.view.StartSearchImage       += this.View_StartSearchImage;
            this.view.StartSearchTranslation += this.View_StartSearchTranslation;

            this.view.SelectImage             += this.View_SelectImage;
            this.view.SelectAudio             += this.View_SelectAudio;
            this.view.GetCheckedData          += this.View_GetCheckedData;
            this.view.UnCheckedAllImage       += this.View_UnCheckedAllImage;
            this.view.GetListWordFromDataBase += this.View_GetListWordFromDataBase;
            this.view.ShotdownApplication     += view_ShotdownApplication;

            this.business.LoaderAudio.LoadingStart          += this.LoaderAudio_LoadingStart;
            this.business.LoaderAudio.LoadingProcessChanged += this.LoaderAudio_LoadingProcessChanged;
            this.business.LoaderAudio.LoadingFileComplite   += this.LoaderAudio_LoadingFileComplite;
            this.business.LoaderAudio.LoadingComplite       += this.LoaderAudio_LoadingComplite;

            this.business.LoaderImages.LoadingStart          += this.LoaderImages_LoadingStart;
            this.business.LoaderImages.LoadingProcessChanged += this.LoaderImages_LoadingProcessChanged;
            this.business.LoaderImages.LoadingFileComplite   += this.LoaderImages_LoadingFileComplite;
            this.business.LoaderImages.LoadingComplite       += this.LoaderImages_LoadingComplite;

            this.business.LoaderTranslation.GettingTranslationStart       += this.LoaderTranslationGettingTranslationStart;
            this.business.LoaderTranslation.GettingOneTranslationComplete += this.LoaderTranslationGettingOneTranslationComplite;
            this.business.LoaderTranslation.GettingTranslationComplete    += this.LoaderTranslationGettingTranslationComplite;
            //// Database.SetInitializer(new System.Data.Entity.DropCreateDatabaseIfModelChanges<TeachEnglishDbModel>());
        }
 public WalletBalancePageViewModel(INavigationService navigationService, ISqLiteService sqLiteService, IHttpRequest httpRequest)
     : base(navigationService: navigationService, sqliteService: sqLiteService, httpRequest: httpRequest)
 {
     AddMoneyCommand = new DelegateCommand(AddMoneyExcute);
     if (App.Settings.IsLogin)
     {
         UserInfo = SqLiteService.Get <UserModel>(user => user.Id != -1);
     }
     AmountCoin = 100;
 }
예제 #4
0
 public override void OnAppear()
 {
     base.OnAppear();
     IsLogin = App.Settings.IsLogin;
     if (IsLogin)
     {
         UserInfo     = SqLiteService.Get <UserModel>(x => x.Id != -1);
         IsAdmin      = UserInfo.IsStore;
         IsExistImage = !string.IsNullOrEmpty(UserInfo.Image);
     }
 }
예제 #5
0
 private async void LogOutExcute()
 {
     await CheckBusy(async() => {
         SqLiteService.DeleteAll <UserModel>();
         SqLiteService.DeleteAll <NotificationModel>();
         App.Settings.IsLogin = false;
         IsAdmin  = false;
         UserInfo = null;
         IsLogin  = false;
         SqLiteService.Update(App.Settings);
     });
 }
예제 #6
0
        public ItemDetailsPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, ISqLiteService sqLiteService, IHttpRequest httpRequest)
            : base(navigationService: navigationService, dialogService: pageDialogService, sqliteService: sqLiteService, httpRequest: httpRequest)
        {
            ShowMoreItemDetailCommand = new DelegateCommand(ShowMoreItemDetailExcute);
            NavigateToCartCommand     = new DelegateCommand(NavigateToCartExcute);
            AddToCartCommand          = new DelegateCommand(AddToCartExcute);
            SubmitReviewCommand       = new DelegateCommand(SubmitReviewExcute);

            if (App.Settings.IsLogin)
            {
                UserInfo = SqLiteService.Get <UserModel>(x => x.Id != -1);
            }
        }
예제 #7
0
 public AddMoneyPageViewModel(INavigationService navigationService, ISqLiteService sqLiteService, IHttpRequest httpRequest)
     : base(navigationService: navigationService, sqliteService: sqLiteService, httpRequest: httpRequest)
 {
     AddCoinCommand        = new DelegateCommand(AddCoinExcute);
     ChooseWayCheckoutList = new ObservableCollection <string>()
     {
         "ATM", "Visa/Credit Card", "Paypal"
     };
     if (App.Settings.IsLogin)
     {
         UserInfo = SqLiteService.Get <UserModel>(user => user.Id != -1);
     }
 }
예제 #8
0
        private async void LogoutExecute()
        {
            await CheckBusy(async() =>
            {
                SqLiteService.DeleteAll <UserModel>();

                // Navigate to Login page
                await DeviceExtension.BeginInvokeOnMainThreadAsync(async() =>
                {
                    await Navigation.NavigateAsync(new Uri($"{ManagerPage.NavigationHomeUri}/{ManagerPage.LoginPage}"));
                });
            });
        }
        public IEnumerable <T> ListByCriteria(TC criteria)
        {
            string sqlQuery = CreateSqlQuery(criteria);

            DataTable dataTable;

            using (var sqlSvc = new SqLiteService())
                dataTable = sqlSvc.ExecuteQuery(sqlQuery);

            var entitiesList = RetrieveEntities(dataTable);

            return(entitiesList);
        }
예제 #10
0
        public CategoryPageViewModel(INavigationService navigationService, ISqLiteService sqLiteService)
            : base(navigationService: navigationService, sqliteService: sqLiteService)
        {
            IsSearchCommand         = new DelegateCommand(IsSearchChangeExcute);
            SelectedCategoryCommand = new DelegateCommand(SelectedCategoryExcute);

            var list = SqLiteService.GetList <Category>(x => x.Id != -1).ToList();

            if (list.Count > 0)
            {
                CategoryList = new ObservableCollection <Category>(list);
            }
            else
            {
                CategoryList = new ObservableCollection <Category>()
                {
                    new Category()
                    {
                        Id           = 1,
                        CategoryName = TranslateExtension.Get("ElectronicsAndGadgets"),
                        Image        = "ic_history",
                    },
                    new Category()
                    {
                        Id           = 2,
                        CategoryName = TranslateExtension.Get("HomeAndFurniture"),
                        Image        = "ic_history",
                    }, new Category()
                    {
                        Id           = 3,
                        CategoryName = TranslateExtension.Get("SportAndHealth"),
                        Image        = "ic_history",
                    }, new Category()
                    {
                        Id           = 4,
                        CategoryName = TranslateExtension.Get("Fashion"),
                        Image        = "ic_history",
                    }, new Category()
                    {
                        Id           = 5,
                        CategoryName = TranslateExtension.Get("OfficeAndIndustry"),
                        Image        = "ic_history",
                    }
                };
                foreach (var item in CategoryList)
                {
                    SqLiteService.Insert(item);
                }
            }
        }
예제 #11
0
        public override void Delete(OrderDto order)
        {
            var existingEntity = ListByCriteria(new OrderCriteriaDto {
                Id = order.Id
            })
                                 .FirstOrDefault();

            if (existingEntity == null)
            {
                return;
            }

            using (var sqlSvc = new SqLiteService())
                sqlSvc.ExecuteQuery($"DELETE FROM orderList WHERE orderID = {existingEntity.Id};");
        }
예제 #12
0
        public override void Update(OrderDto order)
        {
            var existingEntity = ListByCriteria(new OrderCriteriaDto {
                Id = order.Id, Table = order.Table
            })
                                 .FirstOrDefault();

            if (existingEntity == null)
            {
                return;
            }

            using (var sqlSvc = new SqLiteService())
                sqlSvc.ExecuteQuery($"UPDATE orderList SET orderDate = '{order.DateCreated.ToString("dd/MM/yyyy")}', orderTime = '{order.DateCreated.ToString("HH:mm:ss")}', orderSumPrice = {order.TotalAmount} WHERE orderID = {order.Id} AND orderTable = {order.Table};");
        }
예제 #13
0
        public override int Create(OrderDto order)
        {
            using (var sqlSvc = new SqLiteService())
                sqlSvc.ExecuteQuery(@"INSERT INTO orderList (orderTable, orderDate, orderTime, orderSumPrice) VALUES" +
                                    $"({order.Table}, '{order.DateCreated.ToString("dd/MM/yyyy")}', '{order.DateCreated.ToString("HH:mm:ss")}', {order.TotalAmount});");

            var entitySaved = ListByCriteria(new OrderCriteriaDto
            {
                Table       = order.Table,
                TotalAmount = order.TotalAmount,
                DateCreated = order.DateCreated
            }).FirstOrDefault();

            return(entitySaved?.Id ?? 0);
        }
        public override void Update(CategoryDto category)
        {
            var existingEntity = ListByCriteria(new CategoryCriteriaDto {
                Id = category.Id
            })
                                 .FirstOrDefault();

            if (existingEntity == null)
            {
                return;
            }

            using (var sqlSvc = new SqLiteService())
                sqlSvc.ExecuteQuery($"UPDATE itemCategories SET categoryName = '{category.Name}' WHERE categoryID = {existingEntity.Id};");
        }
        public override void Update(ProductDto product)
        {
            var existingEntity = ListByCriteria(new ProductCriteriaDto {
                Id = product.Id
            })
                                 .FirstOrDefault();

            if (existingEntity == null)
            {
                return;
            }

            using (var sqlSvc = new SqLiteService())
                sqlSvc.ExecuteQuery($"UPDATE items SET dateCreated = '{product.DateCreated}', timeCreated = '{product.DateCreated}', itemName = '{product.Name}', itemCategory = '{product.Category}', fixedQuantity = '{product.FixedQuantity}', itemPrice = {product.Price} WHERE itemID = {product.Id};");
        }
        public override void Delete(ProductDto product)
        {
            var existingEntity = ListByCriteria(new ProductCriteriaDto {
                Id = product.Id
            })
                                 .FirstOrDefault();

            if (existingEntity == null)
            {
                return;
            }

            using (var sqlSvc = new SqLiteService())
                sqlSvc.ExecuteQuery($"DELETE FROM items WHERE itemID = {existingEntity.Id};");
        }
        public override void Delete(CategoryDto category)
        {
            var existingEntity = ListByCriteria(new CategoryCriteriaDto {
                Id = category.Id
            })
                                 .FirstOrDefault();

            if (existingEntity == null)
            {
                return;
            }

            using (var sqlSvc = new SqLiteService())
                sqlSvc.ExecuteQuery($"DELETE FROM itemCategories WHERE categoryID = {existingEntity.Id};");
        }
예제 #18
0
        public override void Update(OrderItemDto orderItem)
        {
            var existingEntity = ListByCriteria(new OrderItemCriteriaDto {
                Id = orderItem.Id, OrderId = orderItem.OrderId
            })
                                 .FirstOrDefault();

            if (existingEntity == null)
            {
                return;
            }

            using (var sqlSvc = new SqLiteService())
                sqlSvc.ExecuteQuery($"UPDATE orders SET orderedItemQuantity = '{orderItem.Quantity}', orderedItemName = '{orderItem.Name}'," +
                                    $" orderedItemPrice = {orderItem.Price} WHERE orderedItemID = {orderItem.Id} AND orderID = {orderItem.OrderId};");
        }
예제 #19
0
        public override int Create(OrderItemDto orderItem)
        {
            using (var sqlSvc = new SqLiteService())
                sqlSvc.ExecuteQuery(@"INSERT INTO orders (orderID, orderedItemID, orderedItemQuantity, orderedItemName, orderedItemPrice) VALUES " +
                                    $"({orderItem.OrderId}, {orderItem.Id}, {orderItem.Quantity}, '{orderItem.Name}', {orderItem.Price});");

            var entitySaved = ListByCriteria(new OrderItemCriteriaDto
            {
                OrderId  = orderItem.OrderId,
                Id       = orderItem.Id,
                Name     = orderItem.Name,
                Price    = orderItem.Price,
                Quantity = orderItem.Quantity
            }).FirstOrDefault();

            return(entitySaved?.Id ?? 0);
        }
예제 #20
0
 public ShowCardPageViewModel(INavigationService navigationService, ISqLiteService sqLiteService, IHttpRequest httpRequest)
     : base(navigationService: navigationService, sqliteService: sqLiteService, httpRequest: httpRequest)
 {
     if (!IsNullCart)
     {
         var listItemOfCartTemp = SqLiteService.GetList <OrderDetails>(x => x.Id != "");
         ItemOfOrder = new ObservableCollection <OrderDetails>();
         if (listItemOfCartTemp != null)
         {
             ItemOfOrder = new ObservableCollection <OrderDetails>(listItemOfCartTemp);
             foreach (var item in ItemOfOrder)
             {
                 Total += item.Amount * item.Price;
             }
         }
     }
     NavigateToCheckoutCommand = new DelegateCommand(NavigateToCheckoutExcute);
 }
        public override int Create(CategoryDto category)
        {
            var existingEntity = ListByCriteria(new CategoryCriteriaDto {
                Name = category.Name
            })
                                 .FirstOrDefault();

            if (existingEntity != null)
            {
                return(0);
            }

            using (SqLiteService sqlSvc = new SqLiteService())
                sqlSvc.ExecuteQuery($"INSERT INTO itemCategories (categoryName) VALUES ('{category.Name}');");

            var entitySaved = ListByCriteria(new CategoryCriteriaDto {
                Name = category.Name
            }).FirstOrDefault();

            return(entitySaved?.Id ?? 0);
        }
예제 #22
0
        public App()
        {
            _pageService   = new PageService();
            _sqLiteService = new SqLiteService();
            InitializeComponent();

            Crashes.SetEnabledAsync(true);
            Microsoft.AppCenter.Analytics.Analytics.SetEnabledAsync(true);
            _isCartTableCreated = _pageService.GetIsCartTableCreated().Result;
            string uname = _pageService.ReturnUsername(string.Empty).Result;

            if (String.IsNullOrEmpty(uname))
            {
                MainPage = new LoginView();
            }
            else
            {
                MainPage = new ShellView();
            }
            //MainPage = new TestPage();
            //MainPage = new Calculation();
        }
예제 #23
0
        public ProceedToCheckoutPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, ISqLiteService sqLiteService, IHttpRequest httpRequest)
            : base(navigationService: navigationService, dialogService: pageDialogService, sqliteService: sqLiteService, httpRequest: httpRequest)
        {
            NavigateToWalletCommand = new DelegateCommand(NavigateToWalletExcute);
            if (!IsNullCart)
            {
                var listItemOfCartTemp = SqLiteService.GetList <OrderDetails>(x => x.Id != "");
                ItemOfOrder = new ObservableCollection <OrderDetails>();
                if (listItemOfCartTemp != null)
                {
                    ItemOfOrder = new ObservableCollection <OrderDetails>(listItemOfCartTemp);
                    foreach (var item in ItemOfOrder)
                    {
                        Total += item.Amount * item.Price;
                    }
                }
            }
            ChooseShippingList = new ObservableCollection <string>()
            {
                TranslateExtension.Get("FreeShip"),
                TranslateExtension.Get("Standard"),
                TranslateExtension.Get("Express"),
            };

            ChooseScheduleWay = new ObservableCollection <string>()
            {
                TranslateExtension.Get("Once"),
                TranslateExtension.Get("Twice"),
                TranslateExtension.Get("Third"),
            };

            CheckoutCommand = new DelegateCommand(CheckoutExcute);

            if (App.Settings.IsLogin)
            {
                UserInfo = SqLiteService.Get <UserModel>(x => x.Id != -1);
            }
        }
예제 #24
0
    public void Init(Game game)
    {
        Game = game;

        Transform[] allChildren = GetComponentsInChildren <Transform>(true);
        foreach (Transform child in allChildren)
        {
            switch (child.name)
            {
            case "<body":
                CanvasController = child.GetComponent <CanvasController>();
                break;

            default:
                break;
            }
        }
        CanvasController.Init(this);

        SqLiteService = new SqLiteService("Database.db");

        CameraControl = GetComponent <CameraControl>();
    }
        public override int Create(ProductDto product)
        {
            var existingEntity = ListByCriteria(new ProductCriteriaDto {
                Name = product.Name, Category = product.Category, FixedQuantity = product.FixedQuantity
            })
                                 .FirstOrDefault();

            if (existingEntity != null)
            {
                return(0);
            }

            using (var sqlSvc = new SqLiteService())
                sqlSvc.ExecuteQuery(@"INSERT INTO items (dateCreated, timeCreated, itemName, itemCategory, fixedQuantity, itemPrice)" +
                                    $" VALUES ('{product.DateCreated}', '{product.DateCreated}', '{product.Name}', '{product.Category}', '{product.FixedQuantity}', {product.Price});");

            var entitySaved = ListByCriteria(new ProductCriteriaDto
            {
                Name     = product.Name,
                Category = product.Category
            }).FirstOrDefault();

            return(entitySaved?.Id ?? 0);
        }
예제 #26
0
    public void CleanUpUsers()
    {
        var dataService = new SqLiteService("Database.db");

        dataService.CleanUpUsers();
    }
예제 #27
0
    public void FillDB(SqLiteService service)
    {
        // app
        var app = new app
        {
            name = "KeepScores Complete Edition",
        };

        app.id = service.AddApp(app);

        // game types.
        var game = new game
        {
            app_id = app.id,
            Type   = new type
            {
                name    = "Standard",
                prog_id = "STANDARD"
            },
            unity = true
        };

        service.CreateGame(game);

        game = new game
        {
            app_id = app.id,
            Type   = new type
            {
                name    = "Claim",
                prog_id = "CLAIM"
            },
            unity = true
        };
        service.CreateGame(game);

        game = new game
        {
            app_id = app.id,
            Type   = new type
            {
                name    = "Munchkin",
                prog_id = "MUNCHKIN"
            },
            unity = true
        };
        service.CreateGame(game);

        game = new game
        {
            app_id = app.id,
            Type   = new type
            {
                name    = "Solo/Uno",
                prog_id = "SOLO_UNO"
            },
            unity = true
        };
        service.CreateGame(game);

        game = new game
        {
            app_id = app.id,
            Type   = new type
            {
                name    = "One Night Ultimate Warewolf",
                prog_id = "ONENIGHT_WAREWOLF"
            },
            unity = true
        };
        service.CreateGame(game);

        game = new game
        {
            app_id = app.id,
            Type   = new type
            {
                name    = "Checkers",
                prog_id = "CHECKERS"
            },
            unity = true
        };
        service.CreateGame(game);

        game = new game
        {
            app_id = app.id,
            Type   = new type
            {
                name    = "Backgammon",
                prog_id = "BACKGAMMON"
            },
            unity = true
        };
        service.CreateGame(game);
    }
예제 #28
0
 public void Initialize(Main main, SqLiteService dataService)
 {
     //_main = main;
     _sqLiteService = dataService;
 }
예제 #29
0
 public Downloading()
 {
     _firebaseService = new FirebaseService();
     _sqLiteService   = new SqLiteService();
     _pageService     = new PageService();
 }