public IHttpActionResult AddStage([FromBody] string search) { JObject Json = new JObject(); using (StreamReader sr = new StreamReader(HttpContext.Current.Request.InputStream)) { Json = JsonConvert.DeserializeObject <JObject>(sr.ReadToEnd()); } string Author_id; string Project_id; string Title; string Description; bool State; try { Author_id = Json.Descendants().OfType <JProperty>().First(p => p.Name == "Author_id").Value.ToString(); Project_id = Json.Descendants().OfType <JProperty>().First(p => p.Name == "Project_id").Value.ToString(); Title = Json.Descendants().OfType <JProperty>().First(p => p.Name == "Title").Value.ToString(); Description = Json.Descendants().OfType <JProperty>().First(p => p.Name == "Description").Value.ToString(); State = Convert.ToBoolean(Json.Descendants().OfType <JProperty>().First(p => p.Name == "Description").Value); } catch (System.InvalidOperationException) { return(Content(HttpStatusCode.NotFound, "The request must contain a field query")); } catch (System.FormatException) { return(Content(HttpStatusCode.NotFound, "from and size it must be non-negative integer")); } _stageRepository.AddStage(new Stage(Author_id, Project_id, Title, Description, State, DateTime.Now.Ticks)); return(Ok()); }
public Boolean AddStage(Stage stage) => StageRepository.AddStage(stage);