public ActionResult <Payment> AddPayment(int jobId, PaymentModel[] payment) { IJobDAO jobDAO = new JobDAO(_connection); JobPost post = jobDAO.FindById(jobId); if (post == null) { return(NotFound(new ErrorMessageModel("Post não encontrado!"))); } jobDAO.AddPayment(jobId, payment); return(Ok(payment)); }
public void CanAddPaymentTypeTest() { IEmployerDAO <Employer> employerDAO = new EmployerDAO(_connection); Employer testEmployer = new Employer(); testEmployer.FirstName = "Ema"; testEmployer.LastName = "Coelho"; testEmployer.UserName = "******"; testEmployer.Password = "******"; testEmployer.Email = "*****@*****.**"; testEmployer.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testEmployer.Address = "Lousada"; Employer returnedEmployer = employerDAO.Create(testEmployer); IJobDAO jobPostDAO = new JobDAO(_connection); JobPost testPost = new JobPost(); testPost.Title = "Canalização Estourada"; testPost.Category = Categories.PLUMBING; testPost.ImagePath = "path/image"; testPost.Description = "Grande estouro nos canos da sanita"; testPost.Tradable = true; testPost.InitialPrice = 60.6; testPost.Address = "Lousada"; testPost.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; JobPost jobReturned = jobPostDAO.Create(returnedEmployer.Id, testPost); PaymentModel paymentModel = new PaymentModel(); paymentModel.payments = Payment.MBWAY; PaymentModel[] payments = { paymentModel }; jobPostDAO.AddPayment(jobReturned.Id, payments); JobPost post = jobPostDAO.FindById(jobReturned.Id); Assert.Contains(Payment.MBWAY, post.PaymentMethod); _fixture.Dispose(); }