public ActionResult AddImage(ImageModel image) { //Checking if there is a file if (image.File.ContentLength > 0) { ImageMethods az = new ImageMethods(); OrderezeTask.Image tmpImage = new OrderezeTask.Image(); HttpPostedFileBase file = image.File; string FileExtension = string.Empty; try { FileExtension = System.IO.Path.GetExtension(file.FileName).Substring(1); } catch { } tmpImage.Name = (string.IsNullOrEmpty(file.FileName) ? file.FileName : image.Name + "." + FileExtension); tmpImage.Description = image.Description; tmpImage.ImagePath = "https://geoklar.blob.core.windows.net/images/" + (string.IsNullOrEmpty(file.FileName) ? file.FileName : image.Name + "." + FileExtension); int id = az.AddNewImage(tmpImage); if (id > 0) { BinaryReader b = new BinaryReader(file.InputStream); byte[] binData = b.ReadBytes(file.ContentLength); az.UploadBlob(binData, (string.IsNullOrEmpty(file.FileName) ? file.FileName : image.Name + "." + FileExtension)); return Content("Success :)"); } } //_images.Add(image); return Content("Fail :("); }
public ActionResult DeleteImage(ImageModel image) { int id = 0; id = image.Id; if (id > 0) { ImageMethods az = new ImageMethods(); az.DeleteImage(id); az.DeleteBlob(image.Name); return Content("Success :)"); //_images.Add(image); } return Content("Fail :("); }