Example #1
0
        public virtual OperationResult Delete(Job job)
        {
            try
            {
                using var transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions, TransactionScopeAsyncFlowOption.Enabled);
                _dao.Delete(job);
                transactionScope.Complete();

                return(new OperationResult()
                {
                    Success = true
                });
            }
            catch (Exception e)
            {
                return(new OperationResult()
                {
                    Success = false, Exception = e
                });
            }
        }
Example #2
0
        public ActionResult <SuccessMessageModel> Delete(int id)
        {
            int?employerID = ClaimHelper.GetIdFromClaimIdentity((ClaimsIdentity)this.ControllerContext.HttpContext.User.Identity);

            if (employerID == null)
            {
                return(Unauthorized());
            }

            string  rootPath = this._environment.ContentRootPath;
            IJobDAO JobDAO   = new JobDAO(_connection, rootPath);
            JobPost toDel    = JobDAO.FindById(id);

            if (toDel == null)
            {
                return(NotFound(new ErrorMessageModel("Post não encontrado!")));
            }

            JobDAO.Delete(toDel);
            return(Ok(new SuccessMessageModel("Apagado!")));
        }
        public void CanDeleteJobPostTest()
        {
            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);

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

            testPost.Title         = "Canalização Aberta";
            testPost.Category      = Categories.PLUMBING;
            testPost.Description   = "Cozinha sem canalização";
            testPost.Tradable      = true;
            testPost.InitialPrice  = 66.6;
            testPost.Address       = "Rua aberta";
            testPost.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY };

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

            //Delete
            Assert.True(jobPostDAO.Delete(returnedPost));

            //After delete
            Categories[] categories = { };
            List <JobPostReturnedModel> jobPosts = jobPostDAO.GetJobs(categories, null, null, null, 1);

            Assert.Empty(jobPosts);

            _fixture.Dispose();
        }