Beispiel #1
0
        public async Task <ActionResult <DealDto> > CreateDeal([FromBody] CreateDealRequestModel requestModel)
        {
            DealDto responseModel = await dealService.CreateDeal(
                new CreateDealDto
            {
                Name          = requestModel.Name,
                Currency      = requestModel.Currency,
                OriginalPrice = requestModel.OriginalPrice,
                Price         = requestModel.Price,
                DealValidFrom = requestModel.DealValidFrom,
                DealValidTo   = requestModel.DealValidTo,
                MarketUrl     = requestModel.MarketUrl,
                BuyNowUrl     = requestModel.BuyNowUrl,
                Gender        = requestModel.Gender,
                DealType      = requestModel.DealType,
                BrandId       = requestModel.BrandId,
                CouponCode    = requestModel.CouponCode,
                Images        = requestModel.Images.Select(i => imageWriter.UploadImage(i).Result)
            });

            if (responseModel == null)
            {
                return(InvalidRequest());
            }

            return(CreatedAtAction(nameof(CreateDeal), new { id = responseModel.Id }, responseModel));
        }
Beispiel #2
0
        public async Task <string> UploadImage(IFormFile file, string name)
        {
            var result = await imageWriter.UploadImage(file, name);

            //return new ObjectResult(result)
            return(result);
        }
Beispiel #3
0
        public async Task <IActionResult> UploadImg([FromForm] IFormFile file, [FromForm] string id)
        {
            if (file != null && id != null)
            {
                string avatar = await _imageHandler.UploadImage(file);

                var user  = _accountService.GetById(id);
                var model = new UpdateByFreelancerUserVm
                {
                    Id          = id,
                    Avatar      = avatar,
                    Address     = user.Address,
                    PhoneNumber = user.PhoneNumber
                };
                if (model.Avatar != "Invalid image file")
                {
                    return(Ok(_accountService.UpdateByFreelancer(model)));
                }
                else
                {
                    return(BadRequest("Este tipo de archivo no es admitido"));
                }
            }
            else
            {
                return(BadRequest("Ocurrio un error al cargar la imagen"));
            }
        }
Beispiel #4
0
        public async Task <string> UploadImage(string filedata)

        {
            var result = await _imageWriter.UploadImage(filedata);

            return(result);
        }
Beispiel #5
0
        public async Task <IActionResult> UploadImage(IFormFile file)
        {
            //throw new NotImplementedException();

            var result = await _imageWriter.UploadImage(file);

            return(new ObjectResult(result));
        }
Beispiel #6
0
        public async Task <ActionResult <BrandDto> > CreateBrand([FromBody] CreateBrandRequestModel requestModel)
        {
            BrandDto responseModel = await brandService.CreateBrand(
                new CreateBrandDto
            {
                Name        = requestModel.Name,
                Description = requestModel.Description,
                Url         = requestModel.Description,
                Image       = await imageWriter.UploadImage(requestModel.Image)
            });

            if (responseModel == null)
            {
                return(InvalidRequest());
            }

            return(CreatedAtAction(nameof(CreateBrand), new { id = responseModel.Id }, responseModel));
        }
        /// <summary>
        /// Upload Image Request
        /// </summary>
        /// <param name="files"></param>
        /// <returns></returns>
        public async Task <IActionResult> UploadImage(IEnumerable <IFormFile> files)
        {
            var result = new StringBuilder();

            foreach (var file in files)
            {
                result.Append(await _imageWriter.UploadImage(file, _appEnvironment.WebRootPath + "/images/"));
            }
            return(new ObjectResult(JsonConvert.SerializeObject(result.ToString())));
        }
Beispiel #8
0
        public async Task <IActionResult> UploadImage(IFormFile file)
        {
            Image image = await _imageWriter.UploadImage(file);

            if (image == null)
            {
                ViewData["message"] = "Du uploadede ikke et billede eller noget gik galt, prøv igen";
                return(BadRequest());
            }
            return(await PostImage(image));
        }
Beispiel #9
0
        public async Task <string> UploadImage(IFormFile file)
        {
            var result = await _imageWriter.UploadImage(file);

            if (result == "invalid")
            {
                throw new BadRequestException("Invalid image !");
            }
            //return new ObjectResult(result);
            return(result);
        }
 public string SaveImageFile([FromForm] IFormFile file)
 {
     try
     {
         var validateResult = ValidateInputs(file);
         if (!IsNullOrWhiteSpace(validateResult))
         {
             return(validateResult);
         }
         return(_imageWriter.UploadImage(file,
                                         GlobalParameter.CdnLocalPath + GlobalParameter.PersonImagePath).Result);
     }
     catch (Exception)
     {
         return(Empty);
     }
 }
        public async Task <IActionResult> UploadImg([FromForm] IFormFile file, [FromForm] string id)
        {
            if (file != null && id != null)
            {
                string avatar = await _imageHandler.UploadImage(file);

                var model = new UpdateByFreelancerUserVm
                {
                    Id     = id,
                    Avatar = avatar
                };
                return(Ok(_accountService.UpdateByFreelancer(model)));
            }
            else
            {
                return(BadRequest("Ocurrio un error al cargar la imagen"));
            }
        }
 public Response UploadImage(UploadImageRequest request)
 {
     try
     {
         UploadImageResponse retval = new UploadImageResponseInvalidImageFile();
         var imageUrl = _imageWriter.UploadImage(request.Image);
         if (imageUrl.Result != "")
         {
             retval = new UploadImageResponseOK(imageUrl.Result);
             _dal.UpdateImageUrl(request.DocId, imageUrl.Result);
         }
         return(retval);
     }
     catch (Exception ex)
     {
         return(new ResponseError(ex.Message));
     }
 }
Beispiel #13
0
        public async Task <ImageDto> UploadImage(IFormFile file)
        {
            var extension = _imageWriter.GetImageExtension(file);
            var name      = await _imageWriter.UploadImage(file);

            var image      = new Image();
            var appBaseUrl = MyHttpContext.AppBaseUrl;

            image.Name      = name;
            image.Extension = extension;
            image.Url       = appBaseUrl + "/images/" + name;

            var resultImage = await _imageRepository.AddAsync(image);

            await _imageRepository.SaveAsync();

            var imageDto = _mapper.Map <Image, ImageDto>(resultImage);

            return(imageDto);
        }
Beispiel #14
0
        public ActionResult <string> SaveImage([FromForm] IFormFile file)
        {
            if (file != null)
            {
                string fileName = _imageWriter.UploadImage(file);

                if (!string.IsNullOrEmpty(fileName))
                {
                    return(Ok(fileName));
                }
                else
                {
                    return(BadRequest());
                }
            }
            else
            {
                return(BadRequest());
            }
        }
        public async Task <IActionResult> UploadImage(IFormFile file, int id)
        {
            var individual = await _repository.GetIndividualAsync(id);

            if (!string.IsNullOrEmpty(individual.Image))
            {
                _imageWriter.DeleteImage(individual.Image);
            }

            var newImageLocation = await _imageWriter.UploadImage(file);

            individual.Image = newImageLocation;

            if (await _repository.SaveChangesAsync())
            {
                return(Ok());
            }

            return(BadRequest());
        }
Beispiel #16
0
        public async Task <string> Handle(UploadRoomTypeImageCommand request, CancellationToken cancellationToken)
        {
            var entity = await context.RoomTypes.FindAsync(request.Id);

            if (entity == null)
            {
                throw new NotFoundException(nameof(RoomType), request.Id);
            }

            string image = entity.Image;

            if (!string.IsNullOrEmpty(image))
            {
                try
                {
                    await imageWriter.RemoveImage(image);
                }
                catch (Exception)
                {
                    throw new UploadImageException(request.ImageFile.FileName, typeof(IImageWriter));
                }
            }


            try
            {
                image = await imageWriter.UploadImage(request.ImageFile);
            }
            catch (Exception)
            {
                throw new UploadImageException(request.ImageFile.FileName, typeof(IImageWriter));
            }

            entity.Image = image;

            await context.SaveChangesAsync(cancellationToken);

            return(image);
        }
Beispiel #17
0
 public async Task <Tuple <bool, string> > UploadFile(IFormFile file, string name)
 {
     return(await _imageWriter.UploadImage(file, name));
 }
Beispiel #18
0
        public async Task <bool> UploadImage(IFormFile file, string filePath)
        {
            var result = await _imageWriter.UploadImage(file, filePath);

            return(result);
        }
Beispiel #19
0
 public async Task <IActionResult> UploadImage(IFormFile file)
 {
     return(Ok(await _imageWriter.UploadImage(file, "")));
 }
 public async Task <bool> UploadImage(IFormFile file, string filePath)
 {
     return(await Task.FromResult(_imageWriter.UploadImage(file, filePath)));
 }
        public async Task <string> UploadImage(IFormFile file, string orientation)
        {
            var result = await _imageWriter.UploadImage(file, orientation);

            return(result);
        }
Beispiel #22
0
        public async Task <string> UploadImage(IFormFile file)
        {
            var result = await _imageWriter.UploadImage(file);

            return(result);
        }
Beispiel #23
0
        public async Task <IActionResult> UploadImage(IFormFile file)
        {
            var result = await _imageWriter.UploadImage(file);

            return(new ObjectResult(result));
        }
Beispiel #24
0
 public string UploadImage(IFormFile file, long personalId)
 {
     return(_imageWriter.UploadImage(file, personalId));
 }