public async Task <IActionResult> CerateOrEdit([FromBody] ESysAlarmLevel eSysAlarmLevel) { bool flag = false; try { if (eSysAlarmLevel.ID == 0) { using (var uow = _uowFactory.Create()) { flag = await _SysAlarmLevelRepository.AddAsync(eSysAlarmLevel); uow.SaveChanges(); } if (flag) { return(Ok(new { status = true, message = "success" })); } else { return(Ok(new { status = false, message = "error" })); } } else { using (var uow = _uowFactory.Create()) { flag = await _SysAlarmLevelRepository.UpdateAsync(eSysAlarmLevel); uow.SaveChanges(); } if (flag) { return(Ok(new { status = true, message = "success" })); } else { return(Ok(new { status = false, message = "error" })); } } } catch (Exception ex) { return(Ok(new { status = false, message = ex.Message })); } }
public async Task <bool> UpdateAsync(ESysAlarmLevel eSysAlarmLevel) { string sql = "update Sys_AlarmLevel set AlarmLevel=@AlarmLevel,AlarmType=@AlarmType,iAlarmLevel=@iAlarmLevel where ID=@ID;"; return(await _context.ExecuteAsync(sql, eSysAlarmLevel) > 0); }
public async Task <bool> AddAsync(ESysAlarmLevel eSysAlarmLevel) { string sql = "insert into Sys_AlarmLevel(AlarmLevel,AlarmType,iAlarmLevel) values(@AlarmLevel,@AlarmType,@iAlarmLevel);select @@Identity;"; return(await _context.ExecuteAsync(sql, eSysAlarmLevel) > 0); }