Esempio n. 1
0
        public ActionResult EditUser([Bind(Include = "ID,Name,LastName,StreetAddress,City,ZipCode,Country,Email,Password,BirthDate,PhoneNum,Facebook,Twitter,Linkedin, , Quote, Ocupation")] User user, HttpPostedFileBase Avatar)
        {
            if (Avatar != null)
            {
                string avatar = System.IO.Path.GetFileName(Avatar.FileName);
                string path   = System.IO.Path.Combine(
                    Server.MapPath("~/Images/Avatar"), avatar);
                // file is uploaded
                Avatar.SaveAs(path);

                user.Avatar = avatar;

                //Delete the old image
                var    photoName = (string)Session["Avatar"];
                string fullPath  = Request.MapPath("~/Images/Avatar/"
                                                   + photoName);

                if (System.IO.File.Exists(fullPath))
                {
                    System.IO.File.Delete(fullPath);
                }
            }
            else
            {
                user.Avatar = (string)Session["Avatar"];
            }

            if (ModelState.IsValid)
            {
                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();
                return(View(user));
            }
            return(View(user));
        }
 public ActionResult Edit([Bind(Include = "ID,Name,Icon,Description")] Service service)
 {
     if (ModelState.IsValid)
     {
         db.Entry(service).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(service));
 }
 public ActionResult Edit([Bind(Include = "ID,Title,Description")] Value value)
 {
     if (ModelState.IsValid)
     {
         db.Entry(value).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(value));
 }
Esempio n. 4
0
 public ActionResult Edit([Bind(Include = "ID,Name,Percentage")] Skill skill)
 {
     if (ModelState.IsValid)
     {
         db.Entry(skill).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(skill));
 }
Esempio n. 5
0
 public ActionResult Edit([Bind(Include = "ID,Name")] Tag tag)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tag).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tag));
 }
 public ActionResult Edit([Bind(Include = "ID,Name,LastName,StreetAddress,City,ZipCode,Country,Email,Password,BirthDate,PhoneNum,Facebook,Twitter,Linkedin,Avatar")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
        public ActionResult Edit(PortfolioItemViewModel portfolioItemViewModel, HttpPostedFileBase Image)
        {
            var photoName = db.PortfolioItems.Find(portfolioItemViewModel.ID).Image;

            if (Image != null)
            {
                string ImageName = System.IO.Path.GetFileName(Image.FileName);
                string path      = System.IO.Path.Combine(
                    Server.MapPath("~/Images/PortfolioItems"), ImageName);
                // file is uploaded
                Image.SaveAs(path);

                portfolioItemViewModel.Image = ImageName;

                //Delete the old image

                string fullPath = Request.MapPath("~/Images/PortfolioItems/"
                                                  + photoName);

                if (System.IO.File.Exists(fullPath))
                {
                    System.IO.File.Delete(fullPath);
                }
            }
            else
            {
                portfolioItemViewModel.Image = photoName;
            }

            if (ModelState.IsValid)
            {
                var originalPortfolioItem = db.PortfolioItems.Find(portfolioItemViewModel.ID);
                AddOrUpdateTags(originalPortfolioItem, portfolioItemViewModel.Tags);
                db.Entry(originalPortfolioItem).CurrentValues.SetValues(portfolioItemViewModel);
                db.SaveChanges();

                //db.Entry(portfolioItem).State = EntityState.Modified;
                //db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(portfolioItemViewModel));
        }
Esempio n. 8
0
        public ActionResult Edit([Bind(Include = "ID,Caption")] Slide slide, HttpPostedFileBase Image)
        {
            var photoName = db.Slides.Find(slide.ID).Image;

            if (Image != null)
            {
                string ImageName = System.IO.Path.GetFileName(Image.FileName);
                string path      = System.IO.Path.Combine(
                    Server.MapPath("~/Images/slides"), ImageName);
                // file is uploaded
                Image.SaveAs(path);

                slide.Image = ImageName;

                //Delete the old image

                string fullPath = Request.MapPath("~/Images/slides/"
                                                  + photoName);

                if (System.IO.File.Exists(fullPath))
                {
                    System.IO.File.Delete(fullPath);
                }
            }
            else
            {
                slide.Image = photoName;
            }


            if (ModelState.IsValid)
            {
                db.Entry(slide).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(slide));
        }
Esempio n. 9
0
        public ActionResult Edit([Bind(Include = "ID,Title,Description, RelDate, ItemUrl")] JournalItem journalItem, HttpPostedFileBase Image)
        {
            var photoName = db.JournalItems.Find(journalItem.ID).ImageUrl;

            if (Image != null)
            {
                string ImageName = System.IO.Path.GetFileName(Image.FileName);
                string path      = System.IO.Path.Combine(
                    Server.MapPath("~/Images/JournalItems"), ImageName);
                // file is uploaded
                Image.SaveAs(path);

                journalItem.ImageUrl = ImageName;

                //Delete the old image

                string fullPath = Request.MapPath("~/Images/JournalItems/"
                                                  + photoName);

                if (System.IO.File.Exists(fullPath))
                {
                    System.IO.File.Delete(fullPath);
                }
            }
            else
            {
                journalItem.ImageUrl = photoName;
            }

            if (ModelState.IsValid)
            {
                db.Entry(journalItem).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(journalItem));
        }