public ActionResult Create(RayonM RayonM, HttpPostedFileBase Image) { if (!ModelState.IsValid || Image == null || Image.ContentLength == 0) { RedirectToAction("Create"); } Rayon r = new Rayon() { IdRayon = RayonM.IdRayon, imageR = Image.FileName, //imageR = RayonM.imageR, typeR = RayonM.typeR, description = RayonM.description, flag = RayonM.flag }; Service.Add(r); Service.Commit(); var path = Path.Combine(Server.MapPath("~/Content/Uploads/"), Image.FileName); Image.SaveAs(path); return(RedirectToAction("Index")); }
// GET: Rayon/Delete/5 public ActionResult Delete(int id) { Rayon rayon = new Rayon(); RayonM r = new RayonM(); rayon = Service.GetById((int)id); r.IdRayon = rayon.IdRayon; r.imageR = rayon.imageR; r.typeR = rayon.typeR; r.description = rayon.description; r.flag = rayon.flag; return(View(r)); }
// GET: Rayon/Details/5 public ActionResult Details(int?id) { Rayon rayon = new Rayon(); RayonM r = new RayonM(); rayon = Service.GetById((int)id); int idr = rayon.IdRayon; r.IdRayon = rayon.IdRayon; r.imageR = rayon.imageR; r.typeR = rayon.typeR; r.description = rayon.description; r.flag = rayon.flag; //var productss = ServiceProduct.GetMany(); //productss = productss.Where(p => p.IdRayon == idr); //r.products = productss; return(View(r)); }
public ActionResult DetailsClient(int?id) { Rayon rayon = new Rayon(); RayonM r = new RayonM(); rayon = Service.GetById((int)id); r.IdRayon = rayon.IdRayon; r.imageR = rayon.imageR; r.typeR = rayon.typeR; r.description = rayon.description; r.flag = rayon.flag; //r.products = rayon.products; List <Product> Products = ServiceProduct.GetMany().ToList(); Products = Products.Where(p => p.IdRayon == id).ToList(); //Products = Products.GroupBy(p => p.CategorieP); ViewBag.MyProducts = new SelectList(Products, "IdProduct", "CategorieP"); return(View(r)); }