Exemplo n.º 1
0
 public async Task <ActionResult <string> > UploadProfileImage(Guid id, IFormFile formFile)
 {
     try
     {
         using (var stream = formFile.OpenReadStream())
         {
             var fileName = formFile.FileName;
             return(await profileImageService.UploadProfileImageAsync(id, fileName, stream));
         }
     }
     catch (NotFoundException exc)
     {
         return(Problem(exc.Message, statusCode: StatusCodes.Status404NotFound));
     }
 }
Exemplo n.º 2
0
        public async Task <ActionResult <string> > UploadProfileImage(IFormFile formFile)
        {
            var user = await identityService.GetUserAsync();

            if (user == null)
            {
                return(NotFound());
            }

            var consultantProfile = await applicationDbContext.UserProfiles.FindAsync(user.ProfileId);

            if (consultantProfile == null)
            {
                return(NotFound());
            }

            using (var stream = formFile.OpenReadStream())
            {
                return(await profileImageService.UploadProfileImageAsync(user.ProfileId.GetValueOrDefault(), formFile.FileName, stream));
            }
        }