Ejemplo n.º 1
0
        public async Task <IActionResult> Upload(string id, ImgUploadInputModel input)
        {
            if (id == null)
            {
                return(this.View("Error"));
            }

            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            var result = new List <string>();

            for (int i = 1; i <= 10; i++)
            {
                var file = (IFormFile)input.GetType().GetProperty("File" + i).GetValue(input, null);
                result.Add(await this.imgService.UploadImgAsync(file));
            }

            //this.ViewBag.ImgsPaths = result.ToString();
            await this.imgService.AddImgToCurrentAdAsync(string.Join(",", result), id);

            return(this.Redirect("/"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> ImgUpload(ImgUploadInputModel input)
        {
            if (input.ProductId == null)
            {
                return(this.View("Error"));
            }

            var imgPath = string.Empty;

            for (int i = 1; i <= 4; i++)
            {
                var file = (IFormFile)input.GetType().GetProperty("ProductImg" + i).GetValue(input, null);
                imgPath += await this.imgService.UploadImgAsync(file) + ",";
            }

            await this.imgService.AddImgToCurrentProductAsync(imgPath, input.ProductId);

            return(this.Redirect($"/Administration/Administration/EditProduct?id={input.ProductId}"));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> EditAdImgs(string id, ImgUploadInputModel input)
        {
            if (id == null)
            {
                return(this.View("Error"));
            }

            var result = new List <string>();

            for (int i = 1; i <= 10; i++)
            {
                var file = (IFormFile)input.GetType().GetProperty("File" + i).GetValue(input, null);
                result.Add(await this.imgService.UploadImgAsync(file));
            }

            await this.imgService.AddImgToCurrentAdAsync(string.Join(",", result), id);

            return(this.Redirect("/MyAccount/MyAccount"));
        }