示例#1
0
        public async Task <IActionResult> DeleteRun([FromQuery] int runId)
        {
            var response = new SingleModelResponse <Run>()
                           as ISingleModelResponse <Run>;

            try
            {
                if (runId.ToString() != null)
                {
                    throw new Exception("Run Id is missing");
                }
                response.Model = await Task.Run(() =>
                {
                    Run run = _context.GetRunByID(runId);
                    if (run == null)
                    {
                        throw new Exception("Run does not exist");
                    }
                    _context.Delete(runId);
                    return(run);
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }
示例#2
0
        public IActionResult DeleteRun(int id)
        {
            Run run = _runRepo.GetRunByID(id);

            if (run == null)
            {
                return(NotFound());
            }
            _runRepo.Delete(run);
            _runRepo.SaveRun();
            return(Ok());
        }