public async Task SendLike(string itemId) { if (!int.TryParse(itemId, out int parsedId)) { return; } var model = new LikeItemModel { UserId = sessionHelper.GetCurrentUserId(), ItemId = parsedId }; var result = await likesManager.LikeItemAsync(model); await Clients.Group(itemId.ToString()).SendAsync("OnItemLiked", result, Context.ConnectionId); }
public async Task <IActionResult> Info(int?id) { if (id is null) { id = sessionHelper.GetCurrentUserId(); } var user = await userCrudService.GetAsync(id.Value); if (user is null) { return(RedirectToAction(nameof(Home.Index), nameof(Home))); } sessionHelper.RememberUserId(id.Value); var model = mapper.Map <UserVM>(user); return(View(model)); }
public async Task <IActionResult> Item(int id) { var item = await itemsCrudService.GetAsync(id); if (item is null) { return(RedirectToAction(nameof(Home.Index), nameof(Home))); } sessionHelper.RememberUserId(item.OwnerId); var itemVM = mapper.Map <ItemVM>(item); itemVM.Liked = item.ItemLikes.Any(il => il.UserId == sessionHelper.GetCurrentUserId()); return(View(itemVM)); }
public async Task <IActionResult> Users() { var users = await usersManager.GetAllUsersAsync(); var usersVM = mapper.Map <IEnumerable <AppUserVM> >(users.Where(u => u.Id != sessionHelper.GetCurrentUserId())); return(View(usersVM)); }