public ActionResult Create(PortfolioItemViewModel portfolioItemViewModel, HttpPostedFileBase 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;
            }

            if (ModelState.IsValid)
            {
                var portfolioItem = new PortfolioItem {
                    Title       = portfolioItemViewModel.Title,
                    Description = portfolioItemViewModel.Description,
                    Image       = portfolioItemViewModel.Image,
                    ProjcetUrl  = portfolioItemViewModel.ProjcetUrl,
                };

                AddOrUpdateTags(portfolioItem, portfolioItemViewModel.Tags);
                db.PortfolioItems.Add(portfolioItem);;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(portfolioItemViewModel));
        }
        public ActionResult Create([Bind(Include = "ID,Name,Icon,Description")] Service service)
        {
            if (ModelState.IsValid)
            {
                db.Services.Add(service);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(service));
        }
        public ActionResult Create([Bind(Include = "ID,Title,Description")] Value value)
        {
            if (ModelState.IsValid)
            {
                db.Values.Add(value);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(value));
        }
Esempio n. 4
0
        public ActionResult Create([Bind(Include = "ID,Name,Percentage")] Skill skill)
        {
            if (ModelState.IsValid)
            {
                db.Skills.Add(skill);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(skill));
        }
Esempio n. 5
0
        public ActionResult Create([Bind(Include = "ID,Name")] Tag tag)
        {
            if (ModelState.IsValid)
            {
                db.Tags.Add(tag);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tag));
        }
        public ActionResult Create([Bind(Include = "ID,Name,LastName,StreetAddress,City,ZipCode,Country,Email,Password,BirthDate,PhoneNum,Facebook,Twitter,Linkedin,Avatar")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
Esempio n. 7
0
        public ActionResult Create([Bind(Include = "ID,Image,Caption")] Slide slide, HttpPostedFileBase 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;
            }
            if (ModelState.IsValid)
            {
                db.Slides.Add(slide);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(slide));
        }
Esempio n. 8
0
        public ActionResult Create([Bind(Include = "ID,Title,Description, RelDate, ItemUrl")] JournalItem journalItem, HttpPostedFileBase Image)
        {
            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;
            }

            if (ModelState.IsValid)
            {
                db.JournalItems.Add(journalItem);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(journalItem));
        }
Esempio n. 9
0
        public ActionResult CreateUser([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;
            }

            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index", "Tags"));
            }

            return(View(user));
        }