public async Task <IActionResult> UpdateProfileImageAsync([FromForm] IFormFile file)
        {
            if (file is null)
            {
                return(BadRequest(new { error = "File can't be null" }));
            }
            if (file.IsLargeFile())
            {
                return(BadRequest(new { error = "File size limit exceeded" }));
            }
            if (!file.ContainImage())
            {
                return(BadRequest(new { error = "File is not image" }));
            }
            var binaryData = await file.ToByteArray();

            await _userProfileService.UpdateProfileImageAsync(UserId, binaryData);

            return(NoContent());
        }
Пример #2
0
        public async Task <IActionResult> SetThumbnailAsync([FromRoute] Guid eventId, [FromForm] IFormFile file)
        {
            if (file is null)
            {
                return(BadRequest(new { error = "File can't be null" }));
            }
            if (file.IsLargeFile())
            {
                return(BadRequest(new { error = "File size limit exceeded" }));
            }
            if (!file.ContainImage())
            {
                return(BadRequest(new { error = "File is not image" }));
            }
            var binaryData = await file.ToByteArray();

            await _eventOrganizerService.SetThumbnailAsync(eventId, UserId, binaryData);

            return(NoContent());
        }