예제 #1
0
        public TestSetEditViewModel()
        {
            try
            {
                this.selectedTest    = new TestSet();
                this.testSetsModel   = BootStrapper.Resolve <ITestSetsModel>();
                this.categoriesModel = BootStrapper.Resolve <ICategoriesModel>();

                this.items = new ObservableCollection <TestItem>();
                if (this.selectedTest.Items != null)
                {
                    foreach (TestItem item in this.selectedTest.Items)
                    {
                        this.items.Add(item);
                    }
                }
                this.categories       = this.categoriesModel.GetAll();
                this.languages        = this.testSetsModel.GetAllLanguages();
                this.SelectedLanguage = TestLanguage.English;
            }
            catch (Exception ex)
            {
                ApplicationErrorHandler.HandleException(ex);
            }
        }
예제 #2
0
        /// <summary>
        /// Оновлює категорію
        /// </summary>
        /// <param name="categoriesModel">Екземпляр категорії</param>
        public void Update(ICategoriesModel categoriesModel)
        {
            using (var db = new SqlCeConnection(connectionString))
            {
                try
                {
                    db.Open();
                }
                catch (SqlCeException)
                {
                    throw new Exception("Немає підключення до бази даних.");
                }

                string sqlQuery = "update Categories set Name=@Name, SupplierId=@SupplierId, Link=@Link, Rate=@Rate, Notes=@Notes where Id=@Id";
                var    cmd      = new SqlCeCommand(sqlQuery, db);
                cmd.Prepare();
                cmd.Parameters.AddWithValue("@Name", categoriesModel.Name);
                cmd.Parameters.AddWithValue("@SupplierId", categoriesModel.SupplierId);
                cmd.Parameters.AddWithValue("@Link", categoriesModel.Link);
                cmd.Parameters.AddWithValue("@Rate", categoriesModel.Rate);
                cmd.Parameters.AddWithValue("@Notes", categoriesModel.Notes);
                cmd.Parameters.AddWithValue("@Id", categoriesModel.Id);

                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (SqlCeException)
                {
                    throw new Exception("Помилка оновлення категорії в базі даних.");
                }
            }
        }
예제 #3
0
 public CategoriesViewModel(ICategoriesModel model, IToastService toastService, ILocalizationService localizationService)
 {
     _model               = model;
     _toastService        = toastService;
     _localizationService = localizationService;
     List = new ObservableCollection <CategoryListViewItemViewModel>();
 }
예제 #4
0
        /// <summary>
        /// Додає категорію
        /// </summary>
        /// <param name="categoriesModel">Екземпляр категорії</param>
        public void Add(ICategoriesModel categoriesModel)
        {
            using (var db = new SqlCeConnection(connectionString))
            {
                try
                {
                    db.Open();
                }
                catch (SqlCeException)
                {
                    throw new Exception("Немає підключення до бази даних.");
                }

                string sqlQuery = "insert into Categories(Name, SupplierId, Link, Rate, Notes) values(@Name, @SupplierId, @Link, @Rate, @Notes)";
                var    cmd      = new SqlCeCommand(sqlQuery, db);
                cmd.Prepare();
                cmd.Parameters.AddWithValue("@Name", categoriesModel.Name);
                cmd.Parameters.AddWithValue("@SupplierId", categoriesModel.SupplierId);
                cmd.Parameters.AddWithValue("@Link", categoriesModel.Link);
                cmd.Parameters.AddWithValue("@Rate", categoriesModel.Rate);
                cmd.Parameters.AddWithValue("@Notes", categoriesModel.Notes);

                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (SqlCeException)
                {
                    throw new Exception("Помилка створення категорії в базі даних.");
                }
            }
        }
        public CategoriesViewModel(ICategoriesModel categoriesModel, ICategoriesManager categoriesManager)
        {
            _categoriesModel   = categoriesModel;
            _categoriesManager = categoriesManager;
            Categories         = categoriesModel.Categories;

            CategorySelectedCommand = new DelegateCommand <CategoryItemModel>(OnCategorySelected);
        }
예제 #6
0
 public CategoryItemsViewModel(ICategoriesModel categoriesModel, ICategoriesManager categoriesManager)
 {
     _categoriesModel        = categoriesModel;
     _categoriesManager      = categoriesManager;
     _disposables            = new List <IDisposable>();
     _menuOptionsDisposables = new List <IDisposable>();
     ListItemSelectedCommand = new DelegateCommand <object>(HandleListItemSelected);
     BackCommand             = new DelegateCommand(HandleBackCommand);
     SubscribeToEvents();
 }
예제 #7
0
 public CategoriesViewModel(ICategoriesModel model)
 {
     try
     {
         this.model = model;
         this.GetAllCategories();
     }
     catch (Exception ex)
     {
         ApplicationErrorHandler.HandleException(ex);
     }
 }
예제 #8
0
 public TestSetsViewModel()
 {
     try
     {
         this.testSetsModel   = BootStrapper.Resolve <ITestSetsModel>();
         this.categoriesModel = BootStrapper.Resolve <ICategoriesModel>();
         this.tests           = this.testSetsModel.GetAll();
         this.categories      = this.categoriesModel.GetAll();
     }
     catch (Exception ex)
     {
         ApplicationErrorHandler.HandleException(ex);
     }
 }
예제 #9
0
 public MainViewModel()
 {
     this.categoriesModel = BootStrapper.Resolve <ICategoriesModel>();
     ApplicationConfiguration.ConnectionString = Settings.Default.ConnectionString;
     this.currentViewModel = new TestSetsViewModel();
     ApplicationMessage.Register <string>(this, MessageType.TestAdd, ReceiveTestAddMessage);
     ApplicationMessage.Register <TestSet>(this, MessageType.TestEdit, ReceiveTestEditMessage);
     ApplicationMessage.Register <string>(this, MessageType.TestsDisplay, ReceiveTestsDisplayMessage);
     ApplicationMessage.Register <TestSet>(this, MessageType.TestRun, ReceiveTestRunMessage);
     ApplicationMessage.Register <TestSet>(this, MessageType.TestLearning, ReceiveTestLearningMessage);
     ApplicationMessage.Register <TestSet>(this, MessageType.TestQuestionsDisplay, ReceiveTestDisplayQuestionsMessage);
     ApplicationMessage.Register <string>(this, MessageType.CloseApp, ReceiveCloseAppMessage);
     ApplicationMessage.Register <string>(this, MessageType.PreviousViewDisplay, ReceiveDisplayPreviousMessage);
     ApplicationMessage.Register <Category>(this, MessageType.CategoryEdit, ReceiveCategoryEditMessage);
     ApplicationMessage.Register <string>(this, MessageType.CategoryAdd, ReceiveCategoryAddMessage);
     ApplicationMessage.Register <string>(this, MessageType.CategoriesDisplay, ReceiveCategoriesDisplayMessage);
 }
예제 #10
0
        public void Add(ICategoriesModel model)
        {
            string sqlQuery = "insert into Categories(Name, SupplierId, Link, Rate, Notes) values(@Name, @SupplierId, @Link, @Rate, @Notes)";

            using (var db = new SqlCeConnection(connectionString))
            {
                db.Open();
                var cmd = new SqlCeCommand(sqlQuery, db);
                cmd.Prepare();
                cmd.Parameters.AddWithValue("@Name", model.Name);
                cmd.Parameters.AddWithValue("@SupplierId", model.SupplierId);
                cmd.Parameters.AddWithValue("@Link", model.Link);
                cmd.Parameters.AddWithValue("@Rate", model.Rate);
                cmd.Parameters.AddWithValue("@Notes", model.Notes);
                cmd.ExecuteNonQuery();
                db.Close();
            }
        }
예제 #11
0
        public void Update(ICategoriesModel model)
        {
            var sqlQuery = "update Categories set Name=@Name, SupplierId=@SupplierId, Link=@Link, Rate=@Rate, Notes=@Notes where Id=@Id";

            using (var db = new SqlCeConnection(connectionString))
            {
                db.Open();
                var cmd = new SqlCeCommand(sqlQuery, db);
                cmd.Prepare();
                cmd.Parameters.AddWithValue("@Name", model.Name);
                cmd.Parameters.AddWithValue("@SupplierId", model.SupplierId);
                cmd.Parameters.AddWithValue("@Link", model.Link);
                cmd.Parameters.AddWithValue("@Rate", model.Rate);
                cmd.Parameters.AddWithValue("@Notes", model.Notes);
                cmd.Parameters.AddWithValue("@Id", model.Id);
                cmd.ExecuteNonQuery();
                db.Close();
            }
        }
예제 #12
0
 public CategoryViewModel(Category category, ICategoriesModel model)
 {
     this.model    = model;
     this.Category = category;
 }
 public CategoriesManager(ICategoriesModel categoriesModel, IYourOrderModel yourOrderModel)
 {
     _categoriesModel = categoriesModel;
     _yourOrderModel  = yourOrderModel;
     _subCategoriesNavigationStack = new Stack <CategoryItemModel>();
 }