Esempio n. 1
0
 public static void ValidateUplloadProfilePictuer(FormFileWrapper fileWrapper)
 {
     if (fileWrapper.File == null)
     {
         throw new FormFileNullException(nameof(FormFileWrapper.File));
     }
 }
Esempio n. 2
0
 public static void ValiadateFormFileWrapper(FormFileWrapper fileWrapper, bool optional = false)
 {
     if (fileWrapper.File == null)
     {
         if (optional)
         {
             return;
         }
         throw new FormFileNullException(nameof(fileWrapper.File));
     }
 }
Esempio n. 3
0
        public async Task <IdStringWrapper> UploadImage(FormFileWrapper request, ClaimsPrincipal actingUser)
        {
            var user = await Helper.GetUserByClaim(dbContext, actingUser);

            var imageServiceReq = new Dto.Image.RequestUploadImage
            {
                File      = request.File,
                UserId    = user.Id,
                ImageType = Core.Enums.ImageType.DorehamiAlbum,
            };

            var res = await imageService.UploadImage(imageServiceReq);

            await dbContext.SaveChangesAsync();

            return(res);
        }
Esempio n. 4
0
        public DocumentProfile()
        {
            CreateMap <DocumentViewModel, DocumentDTO>()
            .ForMember(dest => dest.InputOperation, opt => opt.MapFrom(src => src.InputOperationViewModel))
            .ForMember(dest => dest.OutputOperation, opt => opt.MapFrom(src => src.OutputOperationViewModel))
            .ForMember(dest => dest.File, opt => opt.MapFrom(src => src.Document))
            .ReverseMap();

            CreateMap <InputOperationsViewModel, InputOperationsDTO>().ReverseMap();
            CreateMap <OutputOperationsViewModel, OutputOperationsDTO>().ReverseMap();

            CreateMap <FormFileWrapper, FileWrapperDTO>().ConvertUsing((src, dest) =>
            {
                FileWrapperDTO dto = new FileWrapperDTO
                {
                    Name = src.Name
                };
                if (src.File != null)
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        src.File.CopyTo(ms);
                        dto.File = ms.ToArray();
                    }
                }
                return(dto);
            });


            CreateMap <FileWrapperDTO, FormFileWrapper>().ConvertUsing((src, dest) =>
            {
                FormFileWrapper ffw = new FormFileWrapper
                {
                    Name = src.Name
                };
                // iformfile ?!
                return(ffw);
            });
        }
Esempio n. 5
0
 public async Task <IActionResult> UploadProfilePicture([FromForm] FormFileWrapper fileWrapper)
 {
     return(await ExecuteAsync(
                () => service.UploadProfilePicture(fileWrapper, User),
                () => UserValidation.ValidateUplloadProfilePictuer(fileWrapper)));
 }
 public async Task <IActionResult> UploadImage([FromForm] FormFileWrapper fileWrapper)
 {
     return(await ExecuteAsync(
                () => service.UploadImage(fileWrapper, User),
                () => General.ValiadateFormFileWrapper(fileWrapper)));
 }