public void UpdateStationBuyGroup(StationBuyGroup group, string userName) { #region 数据验证 if (string.IsNullOrWhiteSpace(group.ID)) { throw new CustomException(_errorCode, "分组ID不可为空。"); } //组名不可为空 if (string.IsNullOrWhiteSpace(group.GroupName)) { throw new CustomException(_errorCode, "平台分销商组名不可为空。"); } //组名不可超过100字符 if (group.GroupName.Length > 100) { throw new CustomException(_errorCode, "平台分销商组名不能超过100字。"); } //验证组名是否存在 if (_stationBuyGroupRepository.FindAll(q => q.GroupName == group.GroupName && q.ID != group.ID).Count() > 0) { throw new CustomException(_errorCode, "组名" + group.GroupName + "已存在。"); } //描述不可超过200字符 if (group.Description.Length > 200) { throw new CustomException(_errorCode, "描述不能超过100字。"); } //颜色不可为空 if (string.IsNullOrWhiteSpace(group.Color)) { throw new CustomException(_errorCode, "颜色不可为空。"); } //颜色不可超过100字符 if (group.Color.Length > 100) { throw new CustomException(_errorCode, "颜色不能超过100字"); } //必须存在操作员 if (string.IsNullOrWhiteSpace(userName)) { throw new CustomException(_errorCode, "操作用户不可为空。"); } #endregion var oldGroup = _stationBuyGroupRepository.FindAll(q => q.ID == group.ID).FirstOrDefault(); if (oldGroup == null) { throw new CustomException(_errorCode, "分组ID不存在。"); } oldGroup.GroupName = group.GroupName; oldGroup.Description = group.Description; oldGroup.Color = group.Color; oldGroup.LastOperatorUser = userName; oldGroup.LastOperatTime = DateTime.Now; _stationBuyGroupRepository.Update(oldGroup); _unitOfWork.Commit(); }
public void AddStationBuyerGroup(AddStationBuyerGroupRequest request) { StationBuyGroup group = new StationBuyGroup(); group.GroupName = request.GroupName; group.Description = request.Description; group.Color = request.Color; _stationBuyGroupDomainService.AddStationBuyGroup(group, AuthManager.GetCurrentUser().OperatorAccount); }
public void SetStationBuyerGroupInfo(SetStationBuyerGroupInfoRequest dto) { StationBuyGroup group = new StationBuyGroup(); group.ID = dto.ID; group.GroupName = dto.GroupName; group.Description = dto.Description; group.Color = dto.Color; _stationBuyGroupDomainService.UpdateStationBuyGroup(group, AuthManager.GetCurrentUser().OperatorAccount); //_stationBuyGroupDomainService.UpdateStationBuyGroup() }
public void AddStationBuyGroup(StationBuyGroup group, string userName) { #region 数据验证 //组名不可为空 if (string.IsNullOrWhiteSpace(group.GroupName)) { throw new CustomException(_errorCode, "平台分销商组名不可为空。"); } //组名不可超过100字符 if (group.GroupName.Length > 100) { throw new CustomException(_errorCode, "平台分销商组名不能超过100字。"); } //组名是否已存在 if (_stationBuyGroupRepository.FindAll(q => q.GroupName == group.GroupName).Count() > 0) { throw new CustomException(_errorCode, "组名" + group.GroupName + "已存在。"); } //描述不可超过200字符 if (group.Description.Length > 200) { throw new CustomException(_errorCode, "描述不能超过100字。"); } //颜色不可为空 if (string.IsNullOrWhiteSpace(group.Color)) { throw new CustomException(_errorCode, "颜色不可为空。"); } //颜色不可超过100字符 if (group.Color.Length > 100) { throw new CustomException(_errorCode, "颜色不能超过100字"); } //必须存在操作员 if (string.IsNullOrWhiteSpace(userName)) { throw new CustomException(_errorCode, "操作用户不可为空。"); } #endregion //补充最后操作信息 group.LastOperatorUser = userName; group.LastOperatTime = DateTime.Now; _stationBuyGroupRepository.Create(group); _unitOfWork.Commit(); }