Ejemplo n.º 1
0
        public async Task <ActionResult <Donors> > DeleteDonor(int id)
        {
            try
            {
                var donorToDelete = await donorRepository.GetDonor(id);

                if (donorToDelete == null)
                {
                    return(NotFound($"Donor with Id = {id} not found"));
                }

                return(await donorRepository.DeleteDonor(id));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "Error deleting data"));
            }
        }
 public HttpResponseMessage DeleteDonor(int id)
 {
     try
     {
         var deleted = _donorRepository.DeleteDonor(id);
         if (deleted)
         {
             return(Request.CreateResponse
                        (HttpStatusCode.OK));
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Could not modify Contact"));
         }
     }
     catch (Exception)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Exception Occured"));
     }
 }