Exemplo n.º 1
0
        public ActionResult ImageUploadPhotoEdit2(int ProjectSpotlightID)
        {
            var image = Request.Files["image2"];

            if (image == null)
            {
                ViewBag.UploadMessage = "Failed to upload image";
            }
            else
            {
                ViewBag.UploadMessage = String.Format("Got image {0} of type {1} and size {2}",
                                                      image.FileName, image.ContentType, image.ContentLength);

                Stream photoStream = image.InputStream;

                ContactProfile profileId = (from contact in db.ContactProfiles
                                            where contact.PrimaryEmail == User.Identity.Name
                                            select contact).FirstOrDefault();
                ProjectSpotlight refreshModel = db.ProjectSpotlights.FirstOrDefault(r => r.ProjectSpotlightID == ProjectSpotlightID);
                byte[]           photoBytes;

                using (BinaryReader binaryData = new BinaryReader(photoStream))
                {
                    photoBytes = binaryData.ReadBytes((int)photoStream.Length);//must convert long to int
                }

                refreshModel.SpotlightImg_2 = photoBytes;

                db.Entry(refreshModel).State = EntityState.Modified;
                db.SaveChanges();
            }
            ProjectSpotlight finalRefreshModel = db.ProjectSpotlights.FirstOrDefault(r => r.ProjectSpotlightID == ProjectSpotlightID);

            return(View("EditProject", finalRefreshModel));
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            ProjectSpotlight projectSpotlight = db.ProjectSpotlights.Find(id);

            db.ProjectSpotlights.Remove(projectSpotlight);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public ActionResult CreateProject(int ContactID)
        {
            ProjectSpotlight model = new ProjectSpotlight();

            model.ProfileID = ContactID;

            return(View(model));
        }
        //allows images to be uploaded (png, png, gif's. PDF's will not work for storing profile images
        //we had this in our original but took this out at the end. Can be added back in if needed.
        public ActionResult GetProjectImg2(int ProjectId)
        {
            ProjectSpotlight project = db.ProjectSpotlights.Single(p => p.ProjectSpotlightID == ProjectId);

            if (project != null && project.SpotlightImg_2 != null)
            {
                return(new FileContentResult(project.SpotlightImg_2, "image/png"));
            }
            return(null);
        }
Exemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "ProjectSpotlightID,ProfileID,ProjectName,Technologies,DevelopmentTime,ProjectDescription,RepoLink,Image_1,Image_2")] ProjectSpotlight projectSpotlight)
 {
     if (ModelState.IsValid)
     {
         db.Entry(projectSpotlight).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProfileID = new SelectList(db.ContactProfiles, "ProfileId", "FirstName", projectSpotlight.ProfileID);
     return(View(projectSpotlight));
 }
Exemplo n.º 6
0
        public ActionResult DeleteProject(int ProjectSpotlightID)
        {
            ProjectSpotlight project = db.ProjectSpotlights.Single(p => p.ProjectSpotlightID == ProjectSpotlightID);

            if (project == null)
            {
                return(View("NotFound"));
            }

            db.ProjectSpotlights.Remove(project);
            db.SaveChanges();
            return(RedirectToAction("Edit", "Admin"));
        }
Exemplo n.º 7
0
        // GET: ProjectSpotlight_auto_/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProjectSpotlight projectSpotlight = db.ProjectSpotlights.Find(id);

            if (projectSpotlight == null)
            {
                return(HttpNotFound());
            }
            return(View(projectSpotlight));
        }
Exemplo n.º 8
0
        public ActionResult CreateProject(ProjectSpotlight model)
        {
            if (ModelState.IsValid)
            {
                db.ProjectSpotlights.Add(model);
                db.SaveChanges();
            }
            else
            {
                return(RedirectToAction("Index"));
            }

            return(RedirectToAction("EditProject", new { ProjectID = model.ProjectSpotlightID }));
        }
Exemplo n.º 9
0
        // GET: ProjectSpotlight_auto_/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProjectSpotlight projectSpotlight = db.ProjectSpotlights.Find(id);

            if (projectSpotlight == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ProfileID = new SelectList(db.ContactProfiles, "ProfileId", "FirstName", projectSpotlight.ProfileID);
            return(View(projectSpotlight));
        }
Exemplo n.º 10
0
        public ActionResult EditProject(ProjectSpotlight model)
        {
            if (ModelState.IsValid)
            {
                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
                return(View(model));
            }
            else
            {
                return(View(model));
            }

            ProjectSpotlight refreshModel = db.ProjectSpotlights.FirstOrDefault(r => r.ProjectSpotlightID == model.ProjectSpotlightID);

            return(View("EditProject", refreshModel));
        }
Exemplo n.º 11
0
        public ActionResult EditProject(int ProjectID)
        {
            ProjectSpotlight model = db.ProjectSpotlights.FirstOrDefault(r => r.ProjectSpotlightID == ProjectID);

            return(View("EditProject", model));
        }