Exemple #1
0
 //DELETE api/contacts/2
 public HttpResponseMessage Delete(int id)
 {
     try
     {
         bool isContactUpdated = _contactRepository.ChangeContactStatus(id);
         if (isContactUpdated)
         {
             BaseResponse <bool> response = new BaseResponse <bool>();
             response.Data = isContactUpdated;
             return(Request.CreateResponse(HttpStatusCode.OK, response));
         }
         else
         {
             BaseResponse <BasicError> response = new BaseResponse <BasicError>();
             response.Errors = new BasicError(ErrorCodes.DataNotFoundError.ToString(), "Contact not found");
             return(Request.CreateResponse(HttpStatusCode.NotFound, response));
         }
     }
     catch (Exception ex)
     {
         BaseResponse <BasicError> response = new BaseResponse <BasicError>();
         response.Errors = new BasicError(ErrorCodes.TechnicalError.ToString(), ex.Message);
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, response));
     }
 }