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")); } }
public IActionResult Insert(int albumId) { var model = new AddImg { AlbumId = albumId }; return(View(model)); }
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 })); }