public ActionResult AddImage(ImageModel file, HttpPostedFileBase image)
 {
     if (!User.Identity.IsAuthenticated)
     {
         return(RedirectToAction("LogOn", "Account"));
     }
     if (ModelState.IsValid)
     {
         var scope = ObjectScopeProvider1.GetNewObjectScope();
         scope.Transaction.Begin();
         var productFile = new HopestrackDL.File {
             Filename = image.FileName
         };
         Stream fileStream = image.InputStream;
         int    fileLength = image.ContentLength;
         productFile.Filedata = new byte[fileLength];
         fileStream.Read(productFile.Filedata, 0, fileLength);
         productFile.MimeType = image.ContentType;
         productFile.Id       = DateTime.Now.Ticks.ToString();
         scope.Add((productFile));
         scope.Transaction.Commit();
         LoadImages();
         return(View("Images"));
     }
     return(View(file));
 }
 public ActionResult AddImage(ImageModel file, HttpPostedFileBase image)
 {
     if (!User.Identity.IsAuthenticated)
         return RedirectToAction("LogOn", "Account");
     if (ModelState.IsValid)
     {
         var scope = ObjectScopeProvider1.GetNewObjectScope();
         scope.Transaction.Begin();
         var productFile = new HopestrackDL.File { Filename = image.FileName };
         Stream fileStream = image.InputStream;
         int fileLength = image.ContentLength;
         productFile.Filedata = new byte[fileLength];
         fileStream.Read(productFile.Filedata, 0, fileLength);
         productFile.MimeType = image.ContentType;
         productFile.Id = DateTime.Now.Ticks.ToString();
         scope.Add((productFile));
         scope.Transaction.Commit();
         LoadImages();
         return View("Images");
     }
     return View(file);
 }
 public ActionResult Ajaxaddimage(ImageModel file, HttpPostedFileBase image)
 {
     if (ModelState.IsValid)
     {
         var scope = ObjectScopeProvider1.GetNewObjectScope();
         scope.Transaction.Begin();
         var productFile = new HopestrackDL.File {
             Filename = image.FileName
         };
         Stream fileStream = image.InputStream;
         int    fileLength = image.ContentLength;
         productFile.Filedata = new byte[fileLength];
         fileStream.Read(productFile.Filedata, 0, fileLength);
         productFile.MimeType = image.ContentType;
         productFile.Id       = DateTime.Now.Ticks.ToString();
         scope.Add((productFile));
         scope.Transaction.Commit();
         ViewData["Status"] = "Image added successfully.";
         return(View(new ImageModel()));
     }
     return(View(file));
 }
 public ActionResult Ajaxaddimage(ImageModel file, HttpPostedFileBase image)
 {
     if (ModelState.IsValid)
     {
         var scope = ObjectScopeProvider1.GetNewObjectScope();
         scope.Transaction.Begin();
         var productFile = new HopestrackDL.File { Filename = image.FileName };
         Stream fileStream = image.InputStream;
         int fileLength = image.ContentLength;
         productFile.Filedata = new byte[fileLength];
         fileStream.Read(productFile.Filedata, 0, fileLength);
         productFile.MimeType = image.ContentType;
         productFile.Id = DateTime.Now.Ticks.ToString();
         scope.Add((productFile));
         scope.Transaction.Commit();
         ViewData["Status"] = "Image added successfully.";
         return View(new ImageModel());
     }
     return View(file);
 }