public HttpResponseMessage DeleteFriendById([FromUri] int friendId) { Validates validates = new Validates(); MessageViewModel messageAttribute = new MessageViewModel(); String Message = validates.ValidateDelete(friendId); if (Message == String.Empty) { Friend friend = new Friend(); if (friendRepository == null) { FriendRepository friendRepository = new FriendRepository(); friend = friendRepository.GetFriendById(friendId); if (friend != null) { Boolean sucess = friendRepository.DeleteObject(friend, true); if (sucess) { return(new HttpResponseMessage(HttpStatusCode.NoContent)); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not delete record.")); } } else { friend = friendRepository.GetFriendById(friendId); friendRepository.DeleteObject(friend, true); } return(new HttpResponseMessage(HttpStatusCode.NoContent)); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, Message)); }
public HttpResponseMessage DeletePaymentById([FromUri] int paymentId) { Validates validates = new Validates(); MessageViewModel messageAttribute = new MessageViewModel(); String Message = validates.ValidateDelete(paymentId); if (Message == String.Empty) { Payment payment = new Payment(); Boolean sucess; if (paymentRepository == null) { PaymentRepository paymentRepository = new PaymentRepository(); payment = paymentRepository.GetPaymentById(paymentId); if (payment != null) { sucess = paymentRepository.DeleteObject(payment, true); if (sucess) { return(new HttpResponseMessage(HttpStatusCode.NoContent)); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not delete record.")); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Register not found.")); } else { payment = paymentRepository.GetPaymentById(paymentId); sucess = paymentRepository.DeleteObject(payment, true); if (sucess) { return(new HttpResponseMessage(HttpStatusCode.NoContent)); } } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Register not found.")); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, Message)); }