Exemple #1
0
 public IActionResult AddRun(Run run)
 {
     if (ModelState.IsValid)
     {
         _runRepo.AddRun(run);
         _runRepo.SaveRun();
         return(Ok(run.RunId));
     }
     else
     {
         return(BadRequest(ModelState));
     }
 }
Exemple #2
0
        public async Task <IActionResult> AddRun([FromBody] Run run)
        {
            var response = new SingleModelResponse <Run>()
                           as ISingleModelResponse <Run>;

            try
            {
                if (run == null)
                {
                    throw new Exception("Run is missing");
                }
                response.Model = await Task.Run(() =>
                {
                    Run runn = _context.AddRun(run);
                    return(runn);
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }