/// <summary> /// 删除一条或多条数据 /// </summary> /// <returns></returns> public async Task <ApiResult <string> > DeleteAsync(string parm) { var res = new ApiResult <string>() { data = "1", statusCode = 200 }; try { var list = Utils.StrToListString(parm); var dbres = ErpAppSettingDb.Update(m => new ErpAppSetting() { IsDel = true }, m => list.Contains(m.Guid)); if (!dbres) { res.statusCode = (int)ApiEnum.Error; res.message = "删除数据失败~"; } } catch (Exception ex) { res.statusCode = (int)ApiEnum.Error; res.message = ApiEnum.Error.GetEnumText() + ex.Message; } return(await Task.Run(() => res)); }
/// <summary> /// 获得一条数据 /// </summary> /// <returns></returns> public async Task <ApiResult <ErpAppSetting> > GetByGuidAsync(string parm) { var model = ErpAppSettingDb.GetSingle(m => m.Guid == parm); var res = new ApiResult <ErpAppSetting> { statusCode = 200, data = model ?? new ErpAppSetting() { } }; return(await Task.Run(() => res)); }
/// <summary> /// 修改一条数据 /// </summary> /// <returns></returns> public async Task <ApiResult <string> > ModifyAsync(ErpAppSetting parm) { var res = new ApiResult <string>() { data = "1", statusCode = 200 }; try { var dbres = ErpAppSettingDb.Update(parm); if (!dbres) { res.statusCode = (int)ApiEnum.Error; res.message = "修改数据失败~"; } } catch (Exception ex) { res.statusCode = (int)ApiEnum.Error; res.message = ApiEnum.Error.GetEnumText() + ex.Message; } return(await Task.Run(() => res)); }
/// <summary> /// 添加一条数据 /// </summary> /// <returns></returns> public async Task <ApiResult <string> > AddAsync(ErpAppSetting parm) { var res = new ApiResult <string>() { data = "1", statusCode = 200 }; try { parm.Guid = Guid.NewGuid().ToString(); var dbres = ErpAppSettingDb.Insert(parm); if (!dbres) { res.statusCode = (int)ApiEnum.Error; res.message = "插入数据失败~"; } } catch (Exception ex) { res.statusCode = (int)ApiEnum.Error; res.message = ApiEnum.Error.GetEnumText() + ex.Message; } return(await Task.Run(() => res)); }