public ActionResult Delete(int id)
 {
     DigitalPortfolio digitalPortfolio = db.DigitalPortfolio.Find(id);
     int mediaId = digitalPortfolio.MediaID;
     db.DigitalPortfolio.Remove(digitalPortfolio);
     db.SaveChanges();
     bool delete = new MediaController().Delete(mediaId, 1);
     return RedirectToAction("Index");
 }
        public JsonResult DeleteMedia(int id)
        {
            bool delete = new MediaController().Delete(id, 1);

            if (!delete)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return Json("Error. Could not delete file.");
            }

            return Json("Success");
        }
        public JsonResult UploadMedia(IEnumerable<HttpPostedFileBase> files, int? id)
        {
            int? projectId = id;
            int? image = new MediaController().Upload(files)[0];

            if (image == null)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return Json("File failed to upload.");
            }

            ProjectHasMedia projectMedia;

            projectMedia = new ProjectHasMedia();
            projectMedia.MediaID = (int)image;
            projectMedia.ProjectID = projectId;
            projectMedia.CreatedAt = TimeStamp.Now();
            projectMedia.UpdatedAt = TimeStamp.Now();
            db.ProjectHasMedia.Add(projectMedia);
            db.SaveChanges();
            return Json(new { result = (int)image });
        }
        public JsonResult UploadMedia(HttpPostedFileBase file, int id)
        {
            var image = new MediaController().UploadExact(file, "/Assets/Common/images", "logo", true);

            if (image == null)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return Json("File failed to upload.");
            }

            AccountUser accountUser = db.AccountUsers.Find(id);
            db.Entry(accountUser).State = EntityState.Modified;
            accountUser.UpdatedAt = TimeStamp.Now();
            accountUser.MediaID = image;
            db.SaveChanges();

            return Json(new { result = image });
        }
Exemplo n.º 5
0
        public JsonResult UploadMedia(IEnumerable<HttpPostedFileBase> files, int id)
        {
            int? image = new MediaController().Upload(files)[0];

            if (image == null)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return Json("File failed to upload.");
            }

            Project project = db.Projects.Find(id);
            db.Entry(project).State = EntityState.Modified;
            project.UpdatedAt = TimeStamp.Now();
            project.MediaID = image;
            db.SaveChanges();

            return Json(new { result = image });
        }