public void Update(IUserInfoUpdatable fields, out List <UpdatedField> updated) { fields.ThrowIfNull(nameof(fields)); updated = new List <UpdatedField>(); if (PermissionGroup.GroupType != fields.PermissionGroup) { updated.Add(new UpdatedField { FieldName = nameof(PermissionGroup), OldValue = PermissionGroup, NewValue = fields.PermissionGroup }); PermissionGroup = new UserPermissionGroup(fields.PermissionGroup); } if (IsReportEnabled != fields.IsReportEnabled) { updated.Add(new UpdatedField { FieldName = nameof(IsReportEnabled), OldValue = IsReportEnabled, NewValue = fields.IsReportEnabled }); IsReportEnabled = fields.IsReportEnabled; } if (updated.Any()) { Validate(); } }
/// <summary> /// 사용자 정보를 업데이트한다. /// </summary> public UserInfo UpdateUser(string userId, IUserInfoUpdatable fields) { userId.ThrowIfNullOrWhiteSpace(nameof(userId)); fields.ThrowIfNull(nameof(fields)); using (var repo = new UserRepository()) { var user = repo.SelectUser(userId, false); if (user == null) { throw new ObjectNotFoundException($"사용자를 찾을 수 없습니다. 대상: \"{userId}\""); } List <UpdatedField> updated = null; user.Update(fields, out updated); if (repo.UpdateUser(user)) { logger.Info($"사용자 정보를 업데이트하였습니다. 대상: \"{user.UserId}\"" + $"\r\n\r\n" + $"{user}"); } return(user); } }
public void Update(IUserInfoUpdatable fields) { List <UpdatedField> updated = null; this.Update(fields, out updated); }