/// <summary> /// /// </summary> /// <param name="appinfo"></param> /// <returns></returns> public async Task <long> AddAppInfo(DTOAPI_AppInfo appinfo) { long newid = this.IIDGenerator.GetNewID <AppInfo>(); var appInfos = (from x in this.accesser.db.AppInfos where x.AppName == appinfo.appName && x.AppVersion == appinfo.appVersion select x).FirstOrDefault(); if (appInfos != null) { throw new Exception("版本号已存在"); } await this.publishEndpoint.Publish(new AddAppInfoCommand { id = newid, appName = appinfo.appName, appVersion = appinfo.appVersion, bBeta = appinfo.bBeta, bEnable = appinfo.bEnable, bForceUpdate = appinfo.bForceUpdate, bLatest = appinfo.bLatest, url = appinfo.url }); return(newid); }
/// <summary> /// /// </summary> /// <param name="appinfo"></param> /// <returns></returns> public async Task UpdateAppInfo(DTOAPI_AppInfo appinfo) { var _appInfo = this.accesser.Get(appinfo.id); if (_appInfo == null) { throw new Exception("不存在"); } if (_appInfo.AppVersion != appinfo.appVersion) { _appInfo = this.accesser.db.AppInfos.Where(x => x.AppName == appinfo.appName && x.AppVersion == appinfo.appVersion).FirstOrDefault(); if (_appInfo != null) { throw new Exception("版本号已存在"); } } await this.publishEndpoint.Publish(new UpdateAppInfoCommand { id = appinfo.id, bBeta = appinfo.bBeta, bEnable = appinfo.bEnable, bForceUpdate = appinfo.bForceUpdate, bLatest = appinfo.bLatest }); }
public async Task <IActionResult> AddAppInfo([FromBody] DTOAPI_AppInfo appinfo) { try { long newId = await this.services.AddAppInfo(appinfo); return(JsonToCamelCase(newId)); } catch (Exception ex) { return(JsonToCamelCase(ex.Message, 50000, 50000, ex.Message)); } }
public async Task <IActionResult> UpdateAppInfo([FromBody] DTOAPI_AppInfo appinfo) { try { await this.services.UpdateAppInfo(appinfo); return(JsonToCamelCase(new { success = true })); } catch (Exception ex) { return(JsonToCamelCase(ex.Message, 50000, 50000, ex.Message)); } }