Пример #1
0
        public ActionResult Create(ContentTeam contentteam, HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                if (image != null)
                {
                    //get the file name
                    string imageName = image.FileName;

                    //strip the extension from the file name
                    string ext = imageName.Substring(imageName.LastIndexOf("."));

                    //generate a guid for the new image name
                    string imageRename = Guid.NewGuid().ToString();

                    imageRename += ext;

                    //save the image to the productImages folder
                    image.SaveAs(Server.MapPath("~/Content/img/teamPhotos/" + imageRename));

                    //save the imageName to the Product Object
                    contentteam.TeamImage = imageRename;
                }
                if (image == null)
                {
                    contentteam.TeamImage = "noPhoto.jpg";
                }

                db.ContentTeams.AddObject(contentteam);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(contentteam));
        }
Пример #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            ContentTeam contentteam = db.ContentTeams.Single(c => c.TeamID == id);

            db.ContentTeams.DeleteObject(contentteam);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #3
0
        public ActionResult Edit(ContentTeam contentteam, HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                if (image != null)
                {
                    //get the file name
                    string imageName = image.FileName;

                    //strip the extension from the file name
                    string ext = imageName.Substring(imageName.LastIndexOf("."));

                    //generate a guid for the new image name
                    string imageRename = Guid.NewGuid().ToString();

                    imageRename += ext;

                    //save the image to the productImages folder
                    image.SaveAs(Server.MapPath("~/Content/img/teamPhotos/" + imageRename));

                    //save the imageName to the Product Object
                    contentteam.TeamImage = imageRename;
                }
                else
                {
                    contentteam.TeamImage = (from i in db.ContentTeams
                                             where i.TeamID == contentteam.TeamID
                                             select i.TeamImage).Single();
                }

                db.ContentTeams.Attach(contentteam);
                db.ObjectStateManager.ChangeObjectState(contentteam, EntityState.Modified);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(contentteam));
        }
Пример #4
0
        public ActionResult Edit(int id)
        {
            ContentTeam contentteam = db.ContentTeams.Single(c => c.TeamID == id);

            return(View(contentteam));
        }
Пример #5
0
        public ViewResult Details(int id)
        {
            ContentTeam contentteam = db.ContentTeams.Single(c => c.TeamID == id);

            return(View(contentteam));
        }