public async Task <IActionResult> UpdateCheck([FromBodyAttribute] UpdateCheckModel updatedata) { try { await _checkregisterService.UpdateCheck(updatedata); return(Ok()); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
public async Task UpdateCheck(UpdateCheckModel check) { var result = _context.CheckRegister.Where(x => x.Name == check.Name && x.Url == check.Url); if (!result.Any()) { throw new AppException("Name \"" + check.Name + "\" and Url \"" + check.Url + "\" does not exists."); } result.FirstOrDefault(x => x.Name == check.Name && x.Url == check.Url).IsActive = check.IsActive; if (!check.IsActive)//disable job { result.FirstOrDefault(x => x.Name == check.Name && x.Url == check.Url).IsScheduled = false; } _context.CheckRegister.Update(result.FirstOrDefault()); await _context.SaveChangesAsync(); }