public Task Handle(UsersModifiedEvent message, CancellationToken cancellationToken) { // 恭喜您,更新成功,请牢记修改后的信息。 return(Task.CompletedTask); }
public async Task <Response <Users> > Handle(ModifyUsersCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { NotifyValidationErrors(request); return(new Response <Users>("Validation failed.")); } var user = await _UsersRepository.FindByIdAsync(request.Id); if (user == null) { return(new Response <Users>("User not found.")); } #region var address = new Address(request.Province, request.City, request.County, request.Street, request.Detailed); user.Type = request.Type; user.MtypeId = request.MtypeId; user.NickName = request.NickName; user.Surname = request.Surname; user.Name = request.Name; user.RealName = request.RealName; user.Phone = request.Phone; user.Email = request.Email; user.BirthDate = request.BirthDate; user.Sex = request.Sex; user.Age = request.Age; user.Gravatar = request.Gravatar; user.Avatar = request.Avatar; user.Motto = request.Motto; user.Bio = request.Bio; user.Idcard = request.Idcard; user.Major = request.Major; user.Polity = request.Polity; user.NowState = request.NowState; user.State = request.State; user.Address = address; user.Company = request.Company; user.Website = request.Website; user.Weibo = request.Weibo; user.Blog = request.Blog; user.Url = request.Url; user.RegisterTime = request.RegisterTime; user.RegisterIp = request.RegisterIp; user.LastLoginTime = request.LastLoginTime; user.LastLoginIp = request.LastLoginIp; user.LastModifiedTime = request.LastModifiedTime; user.LastModifiedIp = request.LastModifiedIp; user.UserAuths = request.UserAuths.Count > 0 ? request.UserAuths : user.UserAuths; user.Sort = request.Sort; //user.IsSuperMan = request.IsSuperMan; #endregion _UsersRepository.Update(user); //var result = await CommitAsync(); if (await CommitAsync()) { #region var usersmodifiedevent = new UsersModifiedEvent( user.Id, user.Type, user.MtypeId, user.NickName, user.Surname, user.Name, user.RealName, user.Phone, user.Email, user.BirthDate, user.Sex, user.Age, user.Gravatar, user.Avatar, user.Motto, user.Bio, user.Idcard, user.Major, user.Polity, user.NowState, user.State, user.Address.Province, user.Address.City, user.Address.County, user.Address.Street, user.Address.Detailed, user.Company, user.Website, user.Weibo, user.Blog, user.Url, user.RegisterTime, user.RegisterIp, user.LastLoginTime, user.LastLoginIp, user.LastModifiedTime, user.LastModifiedIp, user.UserAuths, user.Sort ); #endregion await Bus.RaiseEvent(usersmodifiedevent); } return(new Response <Users>(user)); }