public void CanMateAddCategoriesTest()
        {
            IMateDAO <Mate> MateDAO  = new MateDAO(_connection);
            Mate            testMate = new Mate();

            testMate.FirstName   = "Jessica";
            testMate.LastName    = "Coelho";
            testMate.UserName    = "******";
            testMate.Password    = "******";
            testMate.Email       = "*****@*****.**";
            testMate.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
            testMate.Address     = "Ordem";
            testMate.Categories  = new[] { Categories.FURNITURE_ASSEMBLE, Categories.TRANSPORTATION };
            testMate.Rank        = Ranks.MATE;
            testMate.Range       = 20;

            Mate          returned = MateDAO.Create(testMate);
            CategoryModel category = new CategoryModel();

            category.categories = Categories.CLEANING;
            CategoryModel[] categories = { category };

            MateDAO.AddCategory(returned.Id, categories);

            Assert.True(MateDAO.CategoriesList(returned.Id).ToList().Exists(a => a.categories == Categories.CLEANING));

            _fixture.Dispose();
        }
示例#2
0
        public void CanMateListWorkCategoriesTest()
        {
            IMateDAO <Mate> MateDAO  = new MateDAO(_connection);
            Mate            testMate = new Mate();

            testMate.FirstName   = "Miguel";
            testMate.LastName    = "Dev";
            testMate.UserName    = "******";
            testMate.Password    = "******";
            testMate.Email       = "*****@*****.**";
            testMate.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
            testMate.Address     = "Figueiró";
            testMate.Categories  = new[] { Categories.CLEANING, Categories.PLUMBING };
            testMate.Rank        = Ranks.SUPER_MATE;
            testMate.Range       = 20;

            Mate returned = MateDAO.Create(testMate);

            List <CategoryModel> category = MateDAO.CategoriesList(returned.Id).ToList();

            Assert.Equal(Categories.PLUMBING, category.ElementAt(0).categories);
            Assert.Equal(Categories.CLEANING, category.ElementAt(1).categories);

            _fixture.Dispose();
        }
示例#3
0
        public ActionResult <List <CategoryModel> > CategoriesList()
        {
            int?mateID = ClaimHelper.GetIdFromClaimIdentity((ClaimsIdentity)this.ControllerContext.HttpContext.User.Identity);

            if (mateID == null)
            {
                return(Unauthorized(new ErrorMessageModel("Utilizador não existe!")));
            }

            MateDAO mateDAO = new MateDAO(_connection);
            List <CategoryModel> categories = mateDAO.CategoriesList((int)mateID).ToList();

            return(categories);
        }