Exemplo n.º 1
0
        public void CanIgnoreValidJobTest()
        {
            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     = "Rua Eng. Luís Carneiro Leão, Nº 54 4590-244 Porto, Portugal";

            Employer returned = EmployerDAO.Create(testEmployer);

            IJobDAO jobPostDAO = new JobDAO(_connection);
            JobPost testPost   = new JobPost();

            testPost.Title         = "Canalização Estourada";
            testPost.Category      = Categories.PLUMBING;
            testPost.Description   = "Grande estouro nos canos da sanita";
            testPost.Tradable      = true;
            testPost.InitialPrice  = 60.6;
            testPost.Address       = "Rua de Salgueiros, Penafiel";
            testPost.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY };

            JobPost jobReturned = jobPostDAO.Create(returned.Id, testPost);

            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     = "Rua de Salgueiros, Penafiel";
            testMate.Categories  = new[] { Categories.CLEANING, Categories.PLUMBING };
            testMate.Rank        = Ranks.SUPER_MATE;
            testMate.Range       = 20;

            Mate returnedMate = MateDAO.Create(testMate);

            IgnoredJobModel job = new IgnoredJobModel();

            job.Id = jobReturned.Id;

            Assert.True(MateDAO.IgnoreJobPost(returnedMate.Id, job));

            Categories[] categories = { Categories.PLUMBING };
            Assert.Empty(jobPostDAO.GetJobs(categories, testMate.Address, 400, null, returnedMate.Id));

            _fixture.Dispose();
        }
Exemplo n.º 2
0
        public ActionResult IgnoreJobPost([FromBody] IgnoredJobModel job)
        {
            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);
            bool    result  = mateDAO.IgnoreJobPost((int)mateID, job);

            if (!result)
            {
                return(UnprocessableEntity(new ErrorMessageModel("Publicação Inválida!")));
            }

            return(Ok(new SuccessMessageModel("Result : " + result)));
        }
        public void ReturnFalselWhenIgnoringAJobThatDoesntExistTest()
        {
            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 returned = 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 returnedMate = MateDAO.Create(testMate);

            IgnoredJobModel job = new IgnoredJobModel();

            job.Id = 1000;

            Assert.False(MateDAO.IgnoreJobPost(returnedMate.Id, job));
            _fixture.Dispose();
        }