Ejemplo n.º 1
0
        public async Task <ActionResult> DeleteDonation(int id)
        {
            var deleted = await donationService.Delete(id);

            if (!deleted)
            {
                return(BadRequest());
            }

            return(Ok());
        }
        public HttpResponseMessage Delete(HttpRequestMessage request, int id)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                if (!ModelState.IsValid)
                {
                    response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var oldDonation = _donationService.Delete(id);
                    _donationService.Save();
                    var responseData = Mapper.Map <Donation, DonationViewModel>(oldDonation);

                    response = request.CreateResponse(HttpStatusCode.OK, responseData);
                }
                return response;
            }));
        }
Ejemplo n.º 3
0
        // DELETE: api/donations/5
        public IHttpActionResult Delete(int id)
        {
            //delete the wish
            Donation donation = service.GetById(id);

            service.Delete(donation);
            service.Commit();



            //update the wish
            Wish wish = wishService.GetById(donation.WishId);

            wish.FundRaised -= donation.Sum;
            wishService.Update(wish);
            wishService.Commit();

            return(Ok());
        }