public IHttpActionResult InsertLeft(int id, HttpRequestMessage content) { // Validate if the content is null if (content.Content == null || string.IsNullOrEmpty(content.Content.ReadAsStringAsync().Result)) { return(BadRequest("Please provide a JSON base64 encoded binary data")); } // Validate if there is a BadRequest if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var data = new Data() { Id = id, LeftSide = content.Content.ReadAsStringAsync().Result }; // Creates the object with all the data needed try { APIsHelper.InsertData(data, APIsHelper.Side.Left, db); // Call the method that insert the record inside the database } catch (Exception ex) { throw ex; } data = db.Data.Find(data.Id); return(Ok(data)); }
public IHttpActionResult DiffContent(int id) { Data data = db.Data.Find(id); // Get the saved left and right encoded Jsons // Validate if the data is null if (data == null) { return(NotFound()); } if (string.IsNullOrEmpty(data.LeftSide) || string.IsNullOrEmpty(data.RightSide)) { return(BadRequest(string.Format("There is a side data missing, please provide the left and right data in the record ID: {0}", data.Id))); } return(Ok(APIsHelper.GetDiff(data))); // Call the method responsable to get the comparison }