public string GetRecommendUser([FromBody] QueryGetRecommend query) { query.Ssid = query.Ssid.Substring(1, query.Ssid.Length - 2); var json = new UserRecommend().GetRecommendInfo(query); return(JsonConvert.SerializeObject(json)); }
public int AddRecommend(UserRecommend eneity) { var query = GetAll(); var item = query.Where(o => o.Recommended == eneity.Recommended).FirstOrDefault(); if (item == null) { eneity.JoinTime = DateTime.Now; return(InsertAndGetId(eneity)); } return(0); }
public async Task <ActionResult> AddRecommend(string username) { var sourceUserId = User.GetUserId(); var recommendedUser = await _userRepository.GetUserByUsernameAsync(username); var sourceUser = await _recommendationsRepository.GetUserWithRecommendations(sourceUserId); if (recommendedUser == null) { return(NotFound()); } if (sourceUser.UserName == username) { return(BadRequest("You cannot recommend yourself")); } var userRecommend = await _recommendationsRepository.GetUserRecommend(sourceUserId, recommendedUser.Id); if (userRecommend != null) { return(BadRequest("You already recommended this user")); } userRecommend = new UserRecommend { SourceUserId = sourceUserId, RecommendedUserId = recommendedUser.Id }; sourceUser.RecommendedUsers.Add(userRecommend); if (await _userRepository.SaveAllAsync()) { return(Ok()); } return(BadRequest("Failed to like user")); }
public bool DeleteEntity(UserRecommend entity) { return(base.DeleteEntity <UserRecommend>(entity)); }
public bool UpdateEntity(UserRecommend entity) { return(base.UpdateEntity <UserRecommend>(entity)); }