public HttpResponseMessage DeleteUnitPrice(UnitPriceModel aUnitPriceModel) { try { if (this.ModelState.IsValid) { var result = service.DeleteUnitPrice(aUnitPriceModel); if (result != null) { return(Request.CreateResponse(HttpStatusCode.OK, result)); } else { string message = "Not deleted successfully"; return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message)); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public HttpResponseMessage SaveUnitPrice(UnitPriceModel aUnitPriceModel) { try { if (this.ModelState.IsValid) { var UnitPriceList = service.SaveUnitPrice(aUnitPriceModel); if (UnitPriceList != null) { return(Request.CreateResponse(HttpStatusCode.OK, UnitPriceList)); } else { string message = "Source language or target language already exist in the database"; return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message)); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message)); } }