public ActionResult <List <MateReviewsModel> > MateReviewsList()
        {
            int?mateID = ClaimHelper.GetIdFromClaimIdentity((ClaimsIdentity)this.ControllerContext.HttpContext.User.Identity);

            // caso o mate id seja nulo
            if (mateID == null)
            {
                return(Unauthorized(new ErrorMessageModel("Utilizador não existe!")));
            }

            ReviewMateDAO           reviewDao   = new ReviewMateDAO(_connection);
            List <MateReviewsModel> reviewsList = reviewDao.MateReviewsList((int)mateID);

            return(Ok(reviewsList));
        }
        public ActionResult <List <MateReviewsModel> > MateReviewsList(int id)
        {
            int?EmployerID = ClaimHelper.GetIdFromClaimIdentity((ClaimsIdentity)this.ControllerContext.HttpContext.User.Identity);

            // caso o employerId seja nulo
            if (EmployerID == null)
            {
                return(Unauthorized(new ErrorMessageModel("Utilizador não existe!")));
            }

            MateDAO mateDao = new MateDAO(_connection);

            if (mateDao.FindMateById(id) == null)
            {
                return(NotFound(new ErrorMessageModel("Mate não Encontrado")));
            }

            ReviewMateDAO           reviewDao   = new ReviewMateDAO(_connection);
            List <MateReviewsModel> reviewsList = reviewDao.MateReviewsList(id);

            return(Ok(reviewsList));
        }
        public void CanReturnMateReviewsTest()
        {
            IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection);
            Employer testEmployer = new Employer();

            testEmployer.FirstName   = "Marcelo";
            testEmployer.LastName    = "Carvalho";
            testEmployer.UserName    = "******";
            testEmployer.Password    = "******";
            testEmployer.Email       = "*****@*****.**";
            testEmployer.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
            testEmployer.Address     = "Lixa";

            Employer returnedEmp = EmployerDAO.Create(testEmployer);

            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);

            MateReview reviewsTest = new MateReview();

            reviewsTest.Rating  = 4;
            reviewsTest.Comment = "O trolha fez um trabalho excelente!";

            MateReview reviewsTest2 = new MateReview();

            reviewsTest2.Rating  = 2;
            reviewsTest2.Comment = "O trolha fez um trabalho mau!";

            IReviewMateDAO ReviewMateDAO   = new ReviewMateDAO(_connection);
            MateReview     returnedReview1 = ReviewMateDAO.ReviewMate(returnedEmp.Id, returned.Id, reviewsTest);
            MateReview     returnedReview2 = ReviewMateDAO.ReviewMate(returnedEmp.Id, returned.Id, reviewsTest2);

            List <MateReviewsModel> ReviewsList = ReviewMateDAO.MateReviewsList(returned.Id);

            MateReviewsModel[] array = ReviewsList.ToArray();

            Assert.Equal(2, array.Length);

            Assert.Equal(reviewsTest.Rating, array[0].Rating);
            Assert.Equal(reviewsTest.Comment, array[0].Comment);
            Assert.Equal(returnedEmp.UserName, array[0].Author);

            Assert.Equal(reviewsTest2.Rating, array[1].Rating);
            Assert.Equal(reviewsTest2.Comment, array[1].Comment);
            Assert.Equal(returnedEmp.UserName, array[1].Author);

            _fixture.Dispose();
        }