public async Task <PartialViewResult> OnGetReplyUserPartialAsync(int pawId, string userPawId) { var userPaw = await _context.UserPaws.Where(x => x.Id.Equals(pawId)).FirstOrDefaultAsync(); var userReplyTo = await _context.ApplicationUsers.Where(x => x.Id.Equals(userPawId)).FirstOrDefaultAsync(); PawVM pawVM = new PawVM(); pawVM.UserPaw = userPaw; pawVM.DisplayName = userReplyTo.DisplayName; pawVM.UserName = userReplyTo.UserName; return(Partial("./Shared/_ModalReply", pawVM)); }
public async Task <PartialViewResult> OnGetSendMeuowePartialAsync(int pawId, string userPawId) { var userPaw = await _context.UserPaws.Where(x => x.Id.Equals(pawId)).FirstOrDefaultAsync(); var userSendMeuowe = await _context.ApplicationUsers.Where(x => x.Id.Equals(userPawId)).FirstOrDefaultAsync(); PawVM pawVM = new PawVM(); pawVM.UserPaw = userPaw; pawVM.DisplayName = userSendMeuowe.DisplayName; pawVM.UserName = userSendMeuowe.UserName; return(Partial("~/Areas/Social/Pages/Shared/_SendMeuowePartial.cshtml", pawVM)); }
public async Task <PartialViewResult> OnGetReplyUserPartialAsync(int pawId, string userPawId) { string userId = _userManager.GetUserId(User); var userPaw = await _context.UserPaws.Where(x => x.Id.Equals(pawId)).FirstOrDefaultAsync(); var userReplyTo = await _context.ApplicationUsers.Where(x => x.Id.Equals(userPawId)).FirstOrDefaultAsync(); PawVM pawVM = new PawVM(); pawVM.UserPaw = userPaw; pawVM.DisplayName = userReplyTo.DisplayName; pawVM.UserName = userReplyTo.UserName; return(Partial("~/Areas/Social/Pages/Shared/_ModalReply.cshtml", pawVM)); }
public PartialViewResult OnGetCreatePawPartial() { PawVM pawVM = new PawVM(); return(Partial("./Shared/_UserCreatePaw", pawVM)); }
private async Task <PawVM> GetItemsAsync(UserPawDBO userPaw) { string userId = _userManager.GetUserId(HttpContext.User); PawVM pawVM = new PawVM(); var user = await(from usr in _context.ApplicationUsers where usr.Id.Equals(userPaw.UserId) select usr).FirstOrDefaultAsync(); var userShake = await(from us in _context.UserShakes where us.UserId.Equals(userId) && us.PawId.Equals(userPaw.Id) select us).FirstOrDefaultAsync(); var userWagTail = await(from uw in _context.UserWags where uw.UserId.Equals(userId) && uw.PawId.Equals(userPaw.Id) select uw).FirstOrDefaultAsync(); int userShakeCount = await _context.UserShakes. Where(x => x.PawId.Equals(userPaw.Id)).CountAsync(); int userWagCount = await _context.UserWags. Where(x => x.PawId.Equals(userPaw.Id)).CountAsync(); if (null != userId && userId.Equals(user.Id)) { pawVM.Relation = 0; } else { pawVM.Relation = 1; } if (null != userShake) { pawVM.UserShake = userShake; } if (null != userWagTail) { pawVM.UserWagTail = userWagTail; } // 2. Connect to Azure Storage account. var connectionString = _configuration.GetConnectionString("AccessKey"); BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString); // 3. Use container for users profile photos. string containerName = "profilephotos"; BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(containerName); // 4. Create new blob and upload to azure storage account. BlobClient blobClient = containerClient.GetBlobClient("profile-" + user.Id + ".png"); if (!blobClient.Exists()) { blobClient = containerClient.GetBlobClient("profiledefault.png"); } //BlobDownloadInfo download = await blobClient.DownloadAsync(); byte[] result = null; using (var ms = new MemoryStream()) { blobClient.DownloadTo(ms); result = ms.ToArray(); } string base64String = Convert.ToBase64String(result); string image = String.Format("data:image/png;base64,{0}", base64String); pawVM.UserPaw = userPaw; pawVM.UserName = user.UserName; pawVM.DisplayName = user.DisplayName; pawVM.UserShakeCount = userShakeCount; pawVM.UserWagCount = userWagCount; pawVM.AzurePhoto = image; return(pawVM); }
public async Task <IViewComponentResult> InvokeAsync(UserPawDBO userPaw) { PawVM pawVM = await GetItemsAsync(userPaw); return(View(pawVM)); }
public async Task <PartialViewResult> OnGetPawRepliesPartialAsync(int pawId) { string userId = _userManager.GetUserId(User); List <PawVM> userPawVM = new List <PawVM>(); var userPaws = await _context.UserPaws.Where(x => x.ParentPawId.Equals(pawId)).ToListAsync(); for (int i = 0; i < userPaws.Count(); i++) { PawVM pawVM = new PawVM(); pawVM.UserPaw = userPaws[i]; var user = await _context.ApplicationUsers. Where(x => x.Id.Equals(userPaws[i].UserId)). FirstOrDefaultAsync(); var userFollow = await _context.UserFollows. Where(x => x.UserParentId.Equals(userId) && x.UserChildId.Equals(userPaws[i].UserId)). FirstOrDefaultAsync(); var userShake = await _context.UserShakes. Where(x => x.UserId.Equals(userId) && x.PawId.Equals(userPaws[i].Id)). FirstOrDefaultAsync(); var userWagTail = await _context.UserWags. Where(x => x.UserId.Equals(userId) && x.PawId.Equals(userPaws[i].Id)). FirstOrDefaultAsync(); int userShakeCount = _context.UserShakes. Where(x => x.PawId.Equals(userPaws[i].Id)).Count(); int userWagCount = _context.UserWags. Where(x => x.PawId.Equals(userPaws[i].Id)).Count(); if (userId.Equals(user.Id)) { pawVM.Relation = 0; } else { pawVM.Relation = 1; } if (null != userFollow) { pawVM.UserFollow = userFollow; } if (null != userShake) { pawVM.UserShake = userShake; } if (null != userWagTail) { pawVM.UserWagTail = userWagTail; } pawVM.UserName = user.UserName; pawVM.DisplayName = user.DisplayName; pawVM.UserShakeCount = userShakeCount; pawVM.UserWagCount = userWagCount; userPawVM.Add(pawVM); } return(Partial("./Shared/_PawPartial", userPawVM)); }