public RespondWebViewData <RespondEditUnitViewModel> EditUnit(RequestWebViewData <RequestEditUnitViewModel> request) { var rData = request.data; if (this.mUnitDataAccess.CheckUnitIsExist(new QueryUnitListParameter { Name = rData.Name, UnitId = rData.UnitId })) { return(new RespondWebViewData <RespondEditUnitViewModel>(WebViewErrorCode.ExistsDataInfo.ErrorCode, string.Format("名称为[{0}]的计量单位已经存在", rData.Name))); } var respond = new RespondWebViewData <RespondEditUnitViewModel>(WebViewErrorCode.Success); this.mDbConnection.ExecuteTransaction(tran => { var unit = this.mUnitDataAccess.GetunitDataModelById(rData.UnitId); if (unit == null) { respond = new RespondWebViewData <RespondEditUnitViewModel>(WebViewErrorCode.NotExistsDataInfo); return; } if (unit.deleted == (short)CommonDeleted.Deleted) { respond = new RespondWebViewData <RespondEditUnitViewModel>(WebViewErrorCode.NotExistsDataInfo); return; } var data = new unitDataModel() { unitid = rData.UnitId, name = rData.Name, status = unit.status, deleted = unit.deleted, sort = rData.Sort }; this.mUnitDataAccess.Update(data, tran); MemcacheHelper.RemoveBy(ServiceMemcachedKeyManageConst.BasicUnit); //由于电脑配置不上mongodb固暂时先屏蔽掉此段mongodb的数据操作 //this.SaveMongoDbData("编辑分公司资料", request, respond, this.GetType()); }); return(respond); }
public RespondWebViewData <RespondAddUnitViewModel> AddUnit(RequestWebViewData <RequestAddUnitViewModel> request) { var rData = request.data; if (this.mUnitDataAccess.CheckUnitIsExist(new QueryUnitListParameter { Name = rData.Name })) { return(new RespondWebViewData <RespondAddUnitViewModel>(WebViewErrorCode.ExistsDataInfo.ErrorCode, string.Format("名称为[{0}]的计量单位已经存在", rData.Name))); } var respond = new RespondWebViewData <RespondAddUnitViewModel>(WebViewErrorCode.Success); try { this.mDbConnection.ExecuteTransaction(tran => { var data = new unitDataModel { name = rData.Name, status = (short)CommonStatus.Used, deleted = (short)CommonDeleted.NotDeleted, sort = rData.Sort }; this.mUnitDataAccess.Add(data, tran); MemcacheHelper.RemoveBy(ServiceMemcachedKeyManageConst.BasicUnit); //由于电脑配置不上mongodb固暂时先屏蔽掉此段mongodb的数据操作 //this.SaveMongoDbData("新增部门资料", request, respond, this.GetType()); }); } catch (Exception ex) { respond = new RespondWebViewData <RespondAddUnitViewModel>(new ErrorCodeItem(WebViewErrorCode.Exception.ErrorCode, ex.Message)); } return(respond); }