Exemple #1
0
        public ActionResult AddImg(AddImg Img)
        {
            System.IO.Stream     stream = Img.PhotoFile.InputStream;
            System.Drawing.Image image  = System.Drawing.Image.FromStream(stream);

            if (image.Height > 128 || image.Width > 128)
            {
                return(View("~/Views/Alert/LoginFailed.cshtml"));
            }

            string caminho = AppDomain.CurrentDomain.BaseDirectory + System.Configuration.ConfigurationManager.AppSettings["ImgPath"] + @"\" + Img.PhotoFile.FileName;

            Img.PhotoFile.SaveAs(caminho);

            string path = "1"; // uploadImage(imgfile)

            if (path.Equals("-1"))
            {
                return(View("~/Views/Alert/LoginFailed.cshtml"));
            }
            else
            {
                AddImg Imgr = new AddImg();
                Imgr.Name  = Img.Name;
                Imgr.Photo = Img.Photo;
                Imgr.Price = System.Configuration.ConfigurationManager.AppSettings["ImgPath"].Replace(@"\", "/") + "/" + Img.PhotoFile.FileName;
                return(View("~/Views/Alert/LoginFailed.cshtml"));
            }
        }
Exemple #2
0
        public IActionResult Insert(int albumId)
        {
            var model = new AddImg
            {
                AlbumId = albumId
            };

            return(View(model));
        }
Exemple #3
0
        public async Task <IActionResult> Insert(AddImg addImg)
        {
            if (addImg.AddImage != null && addImg.AddImage.Length > 0)
            {
                var dto = new Img
                {
                    AlbumId     = addImg.AlbumId,
                    Title       = addImg.Title,
                    Description = addImg.Description
                };
                await service.Update(dto, GetFileBytes(addImg.AddImage));
            }

            return(RedirectToAction("Insert", new { albumId = addImg.AlbumId }));
        }