public IActionResult AskNewFollower([FromBody] string followerName) { if (userGet.HaveUser(HttpContext)) { User user = userGet.GetUser(HttpContext); User followedUser = userRepository.GetUserData(followerName); if (followedUser == null) { return(BadRequest("Not exists user with username!")); } Success success = followerRepository.AskNewFollower(user, followedUser); switch (success) { case (Success.Successfull): return(Ok()); case (Success.FailedByAlreadyRequested): return(BadRequest("Already requested!")); case (Success.FailedByAlreadyFollowed): return(BadRequest("Already followed!")); } } return(Unauthorized()); }
public IActionResult Like([FromBody] int pictureId) { if (userGet.HaveUser(HttpContext)) { User user = userGet.GetUser(HttpContext); return(Ok(likeRepository.SaveLike(pictureId, user))); } return(Unauthorized()); }
public IActionResult OtherUserInfo() { if (userGet.HaveUser(HttpContext)) { User user = userGet.GetUser(HttpContext); return(Ok(new UserPageUser(user, followerRepository.GetAllFollowersNumber(user), followerRepository.GetAllFollowingNumber(user), folderRepository.GetAllFolders(user)))); //User otheruser = userRepository.GetUserData(userId); //return Ok(new UserPageUser(otheruser, followerRepository.GetAllFollowersNumber(otheruser), followerRepository.GetAllFollowingNumber(otheruser), folderRepository.GetAllFoldersForOther(user, otheruser))); } return(Unauthorized()); }
public IActionResult Suggestions([FromBody] string term) { if (userGet.HaveUser(HttpContext)) { User user = userGet.GetUser(HttpContext); if (!term.Contains(" ")) { } List <SearchUser> foundUsers = userRepository.GetUsersForTerm(term); return(Ok(foundUsers)); } return(Unauthorized()); }
public IActionResult GetImageById(string pictureId) { if (pictureId == "0") { return(File(System.IO.File.ReadAllBytes(_hostEnv.WebRootPath + "/0.jpg"), "image/jpg")); } Picture pictureInDB = pictureRepository.GetPicture(int.Parse(pictureId)); if (userGet.HaveUser(HttpContext) && pictureInDB.Type != null) { User user = userGet.GetUser(HttpContext); if (pictureInDB.Access != AccessType.Private || (user.Id == pictureInDB.Owner.Id)) { string path = CreatePathForRetrive(pictureId, pictureInDB.Type); Byte[] picture = System.IO.File.ReadAllBytes(path); return(File(picture, pictureInDB.Type)); } return(BadRequest("Private picture!")); } return(Unauthorized()); }