Exemplo n.º 1
0
        public ActionResult photo(Photo p)
        {
            var Data1 = db.Photos.Add(p);

            Data1.Id   = p.Id;
            Data1.name = p.name;



            int i = 0;

            foreach (string file in Request.Files)
            {
                HttpPostedFileBase hpf = Request.Files[file] as HttpPostedFileBase;


                var validImageTypes = new string[]
                {
                    "image/gif",
                    "image/jpeg",
                    "image/pjpeg",
                    "image/png"
                };



                if (hpf.ContentLength == 0)
                {
                    continue;
                }

                string saveFileName = Path.GetFileName(hpf.FileName);
                string location     = Path.Combine(Server.MapPath("~/Images/" + @"\" + saveFileName));
                Request.Files[file].SaveAs(location);

                if (i >= 2)
                {
                    i = 0;
                }
                // Count + 1 each time
                i++;

                if (i == 1)
                {
                    Data1.path = saveFileName;
                }
            }



            if (ModelState.IsValid)
            {
                db.Entry(Data1).State = EntityState.Modified;

                db.SaveChanges();
            }
            return(View(p));
        }
Exemplo n.º 2
0
        // GET: /ad/Details/5

        public ActionResult Details(int id = 0)
        {
            ad ad = db.ads.Find(id);

            Session["a"] = id;
            view add = db.views.Find(id);

            add.org = add.VId + 1;
            add.VId = add.org;


//          var userResults = from u in db.views
//                          where u.ad_id == id
            //
            //                select u.VId;

            //foreach (var a in userResults)
            //{


            //  int ab= (int)add.VId;



            //}



            db.Entry(add).State = EntityState.Modified;
            // db.views.Add(addd);
            db.SaveChanges();



            if (ad == null)
            {
                return(HttpNotFound());
            }
            return(View(ad));
        }
Exemplo n.º 3
0
        public ActionResult Edit(Iuser iuser)
        {
            var SData = db.Iusers.Add(iuser);

            SData.userId = (int)Session["j"];
            SData.Sitem  = iuser.Sitem;
            SData.Scat   = iuser.Scat;
            SData.Sphone = iuser.Sphone;
            if (ModelState.IsValid)
            {
                db.Entry(SData).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.userId = new SelectList(db.users, "user_id", "name", iuser.userId);
            return(View(iuser));
        }