コード例 #1
0
ファイル: RecordsController.cs プロジェクト: egibra/BCE
 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");
 }
コード例 #2
0
        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");
        }