コード例 #1
0
        public ActionResult Edit(int id, Meuble m, HttpPostedFileBase file)
        {
            Meuble meuble = meubleService.GetById(m.IdMeuble);

            m.UserID = User.Identity.GetUserId <string>();

            meuble.Titre           = m.Titre;
            meuble.DatePublication = DateTime.Now;
            meuble.Image           = file.FileName;
            meuble.PrixM           = m.PrixM;
            meuble.Adresse         = m.Adresse;
            meuble.Adresse         = m.Adresse;
            var fileName = "";

            if (file.ContentLength > 0)
            {
                fileName = Path.GetFileName(file.FileName);
                var path = Path.Combine(Server.MapPath("~/Content/"), fileName);
                file.SaveAs(path);
            }
            if (ModelState.IsValid)
            {
                meubleService.Update(meuble);
                meubleService.Commit();
                return(RedirectToAction("Index"));
            }
            return(View());
        }
コード例 #2
0
        public ActionResult Create(MeubleVm meubleVM, HttpPostedFileBase file)
        {
            Meuble A = new Meuble();

            A.Titre           = meubleVM.Titre;
            A.DatePublication = DateTime.UtcNow;

            A.IdMeuble    = meubleVM.IdMeuble;
            A.Description = meubleVM.Description;
            A.Image       = file.FileName;
            A.PrixM       = meubleVM.PrixM;

            A.Adresse = meubleVM.Adresse;

            var fileName = "";

            if (file.ContentLength > 0)
            {
                var path = Path.Combine(Server.MapPath("~/Content/"), file.FileName);
                file.SaveAs(path);
            }



            //    return RedirectToAction("CreateM");
            //}
            //else
            A.UserID = User.Identity.GetUserId();
            meubleService.Add(A);
            meubleService.Commit();
            //var path = Path.Combine(Server.MapPath("~/Content/Upload/"), Image.FileName);
            //Image.SaveAs(path);
            return(RedirectToAction("AfficherMeuble"));
        }
コード例 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            Meuble meuble = db.Meubles.Find(id);

            db.Meubles.Remove(meuble);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #4
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            Meuble an = meubleService.GetById(id);

            meubleService.Delete(an);
            meubleService.Commit();
            return(RedirectToAction("MesMeubles"));
        }
コード例 #5
0
 public ActionResult Edit([Bind(Include = "IdMeuble,Titre,Category,Image,Description,Prix,Livraison,Etat,Disponibilite,dateAnn,IdClient")] Meuble meuble)
 {
     if (ModelState.IsValid)
     {
         db.Entry(meuble).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IdClient = new SelectList(db.Clients, "IdClient", "Nom", meuble.IdClient);
     return(View(meuble));
 }
コード例 #6
0
        public ActionResult Create(Meuble meuble)
        {
            if (!ModelState.IsValid)
            {
                return(View(meuble));
            }

            meubles.Add(meuble);

            return(RedirectToAction(nameof(Index)));
        }
コード例 #7
0
        // GET: Meubles/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Meuble meuble = db.Meubles.Find(id);

            if (meuble == null)
            {
                return(HttpNotFound());
            }
            return(View(meuble));
        }
コード例 #8
0
        public ActionResult Edit(int id, Meuble MVM)  // FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                Service.Update(MVM);
                Service.Commit();
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #9
0
        // GET: Meubles/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Meuble meuble = db.Meubles.Find(id);

            if (meuble == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IdClient = new SelectList(db.Clients, "IdClient", "Nom", meuble.IdClient);
            return(View(meuble));
        }
コード例 #10
0
        // GET: Meuble/Delete/5
        public ActionResult Delete(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Meuble a = meubleService.GetById(id);

            if (a == null)
            {
                return(HttpNotFound());
            }

            return(View(a));
        }
コード例 #11
0
        public ActionResult Create(Meuble MVM, HttpPostedFileBase file)
        {
            try
            {
                MVM.Image = file.FileName;
                if (file.ContentLength > 0)
                {
                    var path = Path.Combine(Server.MapPath("~/Content/"), file.FileName);
                    file.SaveAs(path);
                }
                Service.Add(MVM);
                Service.Commit();

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }
        }
コード例 #12
0
        // GET: Meuble/Edit/5
        public ActionResult Edit(int id)
        {
            //var userId = User.Identity.GetUserId();
            //string UserName = US.GetById(userId).UserName;
            //string Phone = US.GetById(userId).Phone;
            //string mail = US.GetById(userId).Email;
            //string role = US.GetById(userId).Role;

            //ViewBag.Email = mail;
            //ViewBag.phone = Phone;
            //ViewBag.UserName = UserName;
            //ViewBag.Role = role;
            //ViewBag.authenticated = val1;

            Meuble p = meubleService.GetById(id);

            if (p == null)
            {
                return(HttpNotFound());
            }
            return(View(p));
        }