public async Task <IActionResult> CreateRecord(Record record) { record.DateCreated = DateTime.Now; _repo.Add(record); if (await _repo.SaveAll()) { return(Ok(record)); } throw new Exception("Creating the record failed on save"); }
public async Task <IActionResult> CreateComment(int recordID, Comment comment) { var record = _repo.GetRecord(recordID); if (record.Result == null) { return(BadRequest()); } comment.RecordID = recordID; comment.DateCreated = DateTime.Now; _repo.Add(comment); if (await _repo.SaveAll()) { return(Ok(record)); } throw new Exception("Creating the record failed on save"); }