コード例 #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
                });
            }
        }
コード例 #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!")));
        }
コード例 #3
0
        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();
        }