Exemplo n.º 1
0
        public bool addUserProfilePicture(profilePictureDto profilePictureDto, string url)
        {
            User userToChange = this._dataContext.users.Include(x => x.posts).FirstOrDefault(x => x.id == profilePictureDto.userId);

            userToChange.imageUrl = url;
            return(this._dataContext.SaveChanges() > 0);
        }
Exemplo n.º 2
0
        public ActionResult <String> addUserProfilePicture([FromForm] profilePictureDto profilePictureDto)
        {
            Console.WriteLine(profilePictureDto.userId + "  asdasdasd");
            Console.WriteLine(profilePictureDto.file + "  f");
            if (profilePictureDto.userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized("You are not the User"));
            }
            string photoUrl = this._photoRepo.addPhoto(profilePictureDto.file);

            if (photoUrl != null || photoUrl != "")
            {
                if (!this._userRepo.addUserProfilePicture(profilePictureDto, photoUrl))
                {
                    return("Couldn't upload photo");
                }
            }
            return(photoUrl);
        }