예제 #1
0
        // POST: api/RentalPayments
        public IHttpActionResult Post([FromBody] EditableRentalPayment value)
        {
            var rentalPaymentDao = new RentalPaymentDao();
            var newRentalPayment = rentalPaymentDao.AddNewRentalPayment(value);

            return(Ok(newRentalPayment));
        }
예제 #2
0
        // GET: api/RentalPayments
        public IHttpActionResult Get(Guid?rentalAgreementId = null, Guid?ownerId = null, DateTime?dueAfterDate = null)
        {
            var rentalPaymentDao = new RentalPaymentDao();

            if (rentalAgreementId.HasValue || ownerId.HasValue || dueAfterDate.HasValue)
            {
                return(Ok(rentalPaymentDao.GetFilteredRentalPayments(rentalAgreementId, ownerId, dueAfterDate).OrderByDescending(rp => rp.DueDate)));
            }
            else
            {
                return(Ok(rentalPaymentDao.GetAllRentalPayments()));
            }
        }
예제 #3
0
        // DELETE: api/RentalPayments/5
        public IHttpActionResult Delete(Guid id)
        {
            var rentalPaymentDao = new RentalPaymentDao();
            var didDelete        = rentalPaymentDao.DeleteRentalPayment(id);

            if (didDelete)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                return(NotFound());
            }
        }
예제 #4
0
        // PUT: api/RentalPayments/5
        public IHttpActionResult Put(Guid id, [FromBody] EditableRentalPayment value)
        {
            var rentalPaymentDao     = new RentalPaymentDao();
            var updatedRentalPayment = rentalPaymentDao.UpdateRentalPayment(id, value);

            if (updatedRentalPayment == null)
            {
                return(NotFound());
            }
            else
            {
                return(Ok(updatedRentalPayment));
            }
        }
예제 #5
0
        // GET: api/RentalPayments/5
        public IHttpActionResult Get(Guid id)
        {
            var rentalPaymentDao   = new RentalPaymentDao();
            var foundRentalPayment = rentalPaymentDao.GetRentalPaymentById(id);

            if (foundRentalPayment == null)
            {
                return(NotFound());
            }
            else
            {
                return(Ok(foundRentalPayment));
            }
        }