public void Create(MyDataDTO myDataDto) { if (myDataDto.Title.Contains("ford")) { throw new Exception("No fords allowed!"); } var myData = new MyData { Title = myDataDto.Title, Length = myDataDto.Length, IsTrue = myDataDto.IsTrue }; this.dContext.MyDatas.Add(myData); this.dContext.SaveChanges(); }
public void Post([FromBody] MyDataDTO newData) // Accept a MyData object from body of POST { // Use the service to add data this.theService.Create(newData); }