public async Task <CustomResponse <UserResponse> > GetUser(GetUserModel model) { return(await Task.Run(() => { var user = _usersDataManager.GetUser(new GetUserModel { UserId = model.UserId }); #region Validate User if (user == null) { _infos.Add("User not exist."); return new CustomResponse <UserResponse> { Message = _infos }; } ; #endregion return new CustomResponse <UserResponse> { Succeed = true, Data = new UserResponse { Detail = new UserDetails { Id = user.UserId, UserName = user.UserName, Email = user.Email, Fullname = user.Fullname, Role = user.Role, MobileNumber = user.MobileNumber, BackgroundSummary = user.BackgroundSummary, Skill = user.Skill, CreatedAt = user.CreatedAt, UpdatedAt = user.UpdatedAt }, ProfilePicture = GetProfilePicture(user.UserId), Location = GetUserLocation(user.UserId) } }; })); }
public bool GetUserData(int userId, out UserData userData, out String errorString) { IUsersDataManager usersDataMan = managersFactory.CreateUsersDataManagerr(); User user = usersDataMan.GetUser(userId); if (user == null) { errorString = "User not found"; userData = null; return(false); } userData = new UserData(); userData.ID = user.UserId; userData.Name = user.Name; userData.Albums = new List <AlbumData>(); foreach (var album in user.Albums) { AlbumData albumData = new AlbumData(); albumData.ID = album.AlbumId; albumData.Name = album.Name; albumData.Images = new List <ImageData>(); foreach (var albumImageData in album.ImagesData) { ImageData imageData = new ImageData(); imageData.ID = albumImageData.AlbumImageDataId; imageData.URL = albumImageData.URL; Image image = Image.FromFile(albumImageData.URL); imageData.Height = image.Height; imageData.Width = image.Width; albumData.Images.Add(imageData); } userData.Albums.Add(albumData); } errorString = ""; return(true); }