public async void CargarListaCategorias()
        {
            AnilloProgreso.Visibility = Visibility.Visible;
            List <Category> ListCategorias = new List <Category>();
            Category        categoria;

            try
            {
                foreach (var item in await CategoriesServices.GetCategories())
                {
                    categoria = new Category()
                    {
                        Name = item.Name, Url = item.Url, CategoryID = item.CategoryID
                    };
                    ListCategorias.Add(categoria);
                }
                ListViewCategorias.ItemsSource = ListCategorias;
                Serializar();
                AnilloProgreso.Visibility = Visibility.Collapsed;
            }
            catch (Exception)
            {
                ErrorConexion();
            }
        }
Example #2
0
 public QuestionnairesController()
 {
     _questionnaireService = new QuestionnairesServices();
     _categoryService      = new CategoriesServices();
     _questionsServices    = new QuestionsServices();
     _questionsType        = new QuestionsTypeServices();
     _optionsServices      = new OptionsServices();
 }
        public void Throw_WhenThePassedCategoryIsNull()
        {
            //Arrange
            var categoriesMock = new Mock <IRepository <Category> >();
            CategoriesServices categoriesServices = new CategoriesServices(categoriesMock.Object);

            //Act & Assert
            Assert.Throws <ArgumentNullException>(() => categoriesServices.Create(null));
        }
Example #4
0
        public void Call_AllMethodFromRepositoryOnce()
        {
            // Arrange
            var provinceService = new CategoriesServices(this.repoMocked.Object, this.unitOfWork);

            // Act
            provinceService.GetAll();

            // Assert
            this.repoMocked.Verify(x => x.All, Times.Once);
        }
Example #5
0
        public void ReturnQueryable_WithExactNumbe()
        {
            // Arrange
            var catService = new CategoriesServices(this.repoMocked.Object, this.unitOfWork);

            // Act
            var expectedNumber = catService.GetAll().Count();

            // Assert
            Assert.AreEqual(expectedNumber, this.cat.Count());
        }
Example #6
0
 public QuestionnairesController(QuestionnairesServices _questionnaireService,
                                 CategoriesServices _categoryService,
                                 QuestionsServices _questionsServices,
                                 QuestionsTypeServices _questionsType,
                                 OptionsServices _optionsServices)
 {
     this._questionnaireService = _questionnaireService;
     this._categoryService      = _categoryService;
     this._questionsServices    = _questionsServices;
     this._questionsType        = _questionsType;
     this._optionsServices      = _optionsServices;
 }
        public void ReturnNull_WhenIdParameterIsInvalid()
        {
            // Arrange
            var categoriesMock = new Mock <IRepository <Category> >();
            CategoriesServices categoriesServices = new CategoriesServices(categoriesMock.Object);

            // Act
            Category categoryResult = categoriesServices.GetById(-1);

            // Assert
            Assert.IsNull(categoryResult);
        }
        public void Invoke_TheRepositoryMethodGetAll_Once()
        {
            //Arrange
            var categoriesMock = new Mock <IRepository <Category> >();
            CategoriesServices categoriesServices = new CategoriesServices(categoriesMock.Object);

            //Act
            IEnumerable <Category> categoryResult = categoriesServices.GetAll();

            //Assert
            categoriesMock.Verify(c => c.All(), Times.Once);
        }
Example #9
0
        public void GetId_ShouldbeCalledOnce()
        {
            // Arrange
            var catService  = new CategoriesServices(this.repoMocked.Object, this.unitOfWork);
            var expectedPro = new Category()
            {
                CategorieName = "one", Id = 1
            };
            // Act
            var res = catService.GetId(expectedPro.CategorieName);

            // Assert
            this.repoMocked.Verify(x => x.All, Times.Once);
        }
Example #10
0
        public void ReturnExpectedCategory()
        {
            // Arrange
            var citiesService = new CategoriesServices(this.repoMocked.Object, this.unitOfWork);
            var expectedPro   = new Category()
            {
                CategorieName = "one", Id = 1
            };

            // Act
            var res = citiesService.GetId(expectedPro.CategorieName);

            // Assert
            Assert.AreEqual(expectedPro.Id, res);
        }
 private void ValidateQuestionModel(Question question)
 {
     if (question.Category_Id != 0)
     {
         Category category = new CategoriesServices().GetById(question.Category_Id);
         if (_questionsServices.IsTextDuplicated(category.Questionnaire_Id.Value, question.Text))
         {
             ModelState.AddModelError(ViewRes.Controllers.Questions.Text, ViewRes.Controllers.Questions.TextText);
         }
         if (_questionsServices.IsSortOrderValid(category.Questionnaire_Id.Value, (int)question.SortOrder))
         {
             ModelState.AddModelError(ViewRes.Controllers.Questions.SortOrder, ViewRes.Controllers.Questions.SortOrderText);
         }
     }
 }
        public JsonResult GetCategoriesByQuestionnaire(int questionnaire_id)
        {
            List <object>      categories       = new List <object>();
            CategoriesServices categorieService = new CategoriesServices();

            foreach (var category in categorieService.GetCategoriesForDropDownList(questionnaire_id))
            {
                categories.Add(
                    new
                {
                    optionValue   = category.Key,
                    optionDisplay = category.Value,
                });
            }
            return(Json(categories));
        }
        public void InvokeRepositoryMethodAddOnce_WhenThePassedCategoryIsValid()
        {
            //Arrange
            var categoriesMock = new Mock <IRepository <Category> >();
            CategoriesServices categoriesServices = new CategoriesServices(categoriesMock.Object);
            int      categoryId = 6;
            Category category   = new Category()
            {
                Id = categoryId, Name = "Cards"
            };

            //Act
            categoriesServices.Create(category.Name);

            //Assert
            categoriesMock.Verify(x => x.Add(It.IsAny <Category>()), Times.Once);
        }
        public async void obtenerproductos()
        {
            try
            {
                List <Category> cat = await CategoriesServices.GetCategories();

                categoria = new ObservableCollection <Category>(cat);
                new Almacenar <Category>().Serialize(categoria, "categorias.json");
                if (categoria != null && categoria.Count != 0)
                {
                    lstcategoria.ItemsSource = categoria;
                }
            }
            catch (Exception)
            {
                //MessageBox.Show("no inter");
            }
        }
        public void ReturnNull_WhenReposityMethodGetAll_ReturnsNull()
        {
            //Arrange
            var categoriesMock = new Mock <IRepository <Category> >();

            categoriesMock.Setup(c => c.All()).Returns(() =>
            {
                return(null);
            });

            CategoriesServices categoriesServices = new CategoriesServices(categoriesMock.Object);

            //Act
            IEnumerable <Category> categoryResult = categoriesServices.GetAll();

            //Assert
            Assert.IsNull(categoryResult);
        }
        public void ReturnResultOfCorrectType()
        {
            //Arrange
            var categoriesMock = new Mock <IRepository <Category> >();

            categoriesMock.Setup(c => c.All()).Returns(() =>
            {
                IEnumerable <Category> expectedResultCollection = new List <Category>();
                return(expectedResultCollection);
            });

            CategoriesServices categoriesServices = new CategoriesServices(categoriesMock.Object);

            //Act
            IEnumerable <Category> categoryResult = categoriesServices.GetAll();

            //Assert
            Assert.That(categoryResult, Is.InstanceOf <IEnumerable <Category> >());
        }
        public void ReturnResult_WhenInvokingRepositoryMethod_GetAll()
        {
            //Arrange
            var categoriesMock = new Mock <IRepository <Category> >();
            IEnumerable <Category> expectedResultCollection = new List <Category>();

            categoriesMock.Setup(c => c.All()).Returns(() =>
            {
                return(expectedResultCollection);
            });

            CategoriesServices categoriesServices = new CategoriesServices(categoriesMock.Object);

            //Act
            IEnumerable <Category> categoryResult = categoriesServices.GetAll();

            //Assert
            Assert.That(categoryResult, Is.EqualTo(expectedResultCollection));
        }
        public bool addCategory(string _name, string _tarif, string _fine, string _ID)
        {
            bool  check = false;
            float n;

            if (!(string.IsNullOrEmpty(_name) || string.IsNullOrEmpty(_tarif.ToString()) ||
                  string.IsNullOrEmpty(_tarif.ToString()) || string.IsNullOrEmpty(_ID)))
            {
                if (!float.TryParse(_tarif, out n) || !float.TryParse(_fine, out n))
                {
                    return(check);
                }
                Category           category = new Category(_ID, _name, float.Parse(_tarif), float.Parse(_fine));
                CategoriesServices service  = new CategoriesServices();

                check = service.addCategoryToDB(category);
            }
            return(check);
        }
        public void ReturnCategory_WhenIdIsValid()
        {
            //Arrange
            var      categoriesMock = new Mock <IRepository <Category> >();
            int      categoryId     = 1;
            Category category       = new Category()
            {
                Id = categoryId, Name = "Category1"
            };

            categoriesMock.Setup(c => c.GetById(categoryId)).Returns(category);

            CategoriesServices categoriesServices = new CategoriesServices(categoriesMock.Object);

            //Act
            Category categoryResult = categoriesServices.GetById(categoryId);

            //Assert
            Assert.AreSame(category, categoryResult);
        }
Example #20
0
 public HomeController()
 {
     this.articlesService   = new ArticlesService();
     this.categoriesService = new CategoriesServices();
 }
        public static async Task <ObservableCollection <Category> > InitializeAllCategoriesAsync()
        {
            var categoriesServices = new CategoriesServices();

            return(await categoriesServices.GetAllComponentsAsync());
        }
 public ArticlesController(ArticlesServices articles, CategoriesServices categories, TagsServices tags)
 {
     this.articles   = articles;
     this.categories = categories;
     this.tags       = tags;
 }
 public CategoriesController(CategoriesServices categoriesServices)
 {
     this.categoriesServices = categoriesServices;
 }
Example #24
0
 public static void LoadMarketById(int[] categoryArray, Action <float> updateCallback = null, Action successCallback = null, Action <string> errorCallback = null)
 {
     StaticCoroutine.DoCoroutine(CategoriesServices.LoadMarketById(categoryArray, updateCallback, successCallback, errorCallback));
 }
 public CategoriesPresenter()
 {
     categoryService = new CategoriesServices();
 }
Example #26
0
        async void CargarDatos()
        {
            try
            {
                pgrBar.Visibility = Visibility.Visible;
                brdMain.Opacity   = 0;
                List <Product> pro = await ProductsServices.GetRecentProducts(10);

                StreamWriter escritor = new StreamWriter("D:\\registros.json");
                //Guarda Productos
                json = JsonConvert.SerializeObject(pro);
                escritor.WriteLine(json);
                escritor.Close();
                lstProductos.ItemsSource = pro;
                pro = await ProductsServices.GetTopProducts(10);

                jsonDest = JsonConvert.SerializeObject(pro);
                StreamWriter escritor1 = new StreamWriter("D:\\registros1.json");
                //Guarda Destacados
                escritor1.WriteLine(jsonDest);
                escritor1.Close();
                lstProductosDest.ItemsSource = pro;
                List <Category> cat = await CategoriesServices.GetCategories();

                jsonCat = JsonConvert.SerializeObject(pro);
                StreamWriter escritor2 = new StreamWriter("D:\\registros2.json");
                //Guarda Categorias
                escritor2.WriteLine(jsonCat);
                escritor2.Close();
                lstCategorias.ItemsSource = cat;
                pgrBar.Visibility         = Visibility.Collapsed;
                textb.Visibility          = Visibility.Collapsed;
                brdMain.Opacity           = 1;
            }
            catch (Exception)
            {
                //productos
                StreamReader lector = new StreamReader("D:\\registros.json");

                json = lector.ReadToEnd();
                lector.Close();
                //Destacados
                StreamReader lector1 = new StreamReader("D:\\registros1.json");
                jsonDest = lector1.ReadToEnd();
                lector1.Close();
                //Categirias
                StreamReader lector2 = new StreamReader("D:\\registros2.json");
                jsonCat = lector2.ReadToEnd();
                lector2.Close();

                List <Product> res = JsonConvert.DeserializeObject <List <Product> > (json);

                List <Product> resDest = JsonConvert.DeserializeObject <List <Product> >(jsonDest);
                List <Product> resCat  = JsonConvert.DeserializeObject <List <Product> >(jsonCat);

                lstProductos.ItemsSource     = res;
                lstProductosDest.ItemsSource = resDest;
                lstCategorias.ItemsSource    = resCat;

                pgrBar.Visibility = Visibility.Collapsed;
                textb.Visibility  = Visibility.Collapsed;
                brdMain.Opacity   = 1;
            }
        }
 public CategoriesController()
 {
     _categoryService = new CategoriesServices();
 }
Example #28
0
 public static void GetListCategories(Action successCallback = null, Action <string> errorCallback = null)
 {
     StaticCoroutine.DoCoroutine(CategoriesServices.GetList(successCallback, errorCallback));
 }
 public CategoriesController(CategoriesServices _categoryService)
 {
     this._categoryService = _categoryService;
 }
 public CategoryController()
 {
     this.categoryService = new CategoriesServices();
     this.articlesService = new ArticlesService();
     this.likesService    = new LikesService();
 }