public ActionResult Duzenle(int id) { Raflar rafs = new Raflar(); // _fncDropDoldur(); // RafKategori rafurun = new RafKategori(); Session["KatID"] = id.ToString(); rafs.Mamul = db.Kategori.FirstOrDefault(x => x.KategoriID == id); rafs.RafList = db.Raf.ToList(); var rafss = db.RafUrun.Where(a => a.KategoriID == id).ToList(); List <Raf> model = new List <Raf>(); foreach (var item in rafss) { Raf secilen = new Raf(); secilen.RafID = Convert.ToInt32(item.RafID); secilen.RafAdi = item.Raf.RafAdi; model.Add(secilen); } rafs.RafM = model; // rafs.RafM = db.RafUrun.Where(a => a.KategoriID == id).ToList(); // ViewBag.Raf = new MultiSelectList(raf, "RafID", "RafAdi"); //IList<SelectListItem> items = new List<SelectListItem>(); //foreach (var item in raf) //{ // items.Add(new SelectListItem { Text = item.Raf.RafAdi, Value = item.RafID.ToString() }); //} //rafurun.RafM = items; return(View(rafs)); }
public ActionResult Delete(Raflar raflar) { var draf = db.Raflar.FirstOrDefault(c => c.ID == raflar.ID); db.Raflar.Remove(draf); db.SaveChanges(); return(RedirectToAction("Index", "Raflar")); }
public ActionResult Create(Raflar raflar) { raflar.olusturmaTarihi = DateTime.Now; raflar.isActive = true; db.Raflar.Add(raflar); db.SaveChanges(); return(RedirectToAction("Index", "Raflar")); }
public ActionResult Duzenle(int id) { string value = CookieSorgula("id"); if (value != null) { Session["id"] = CookieSorgula("id"); Session["isim"] = CookieSorgula("isim"); try { Session["resim"] = CookieSorgula("resim"); } catch (Exception) { } Raflar rafs = new Raflar(); //Kategori kategori = new Kategori(); Session["UrunID"] = id.ToString(); rafs.YariMamul = db.Urun.FirstOrDefault(x => x.UrunID == id); rafs.RafList = db.Raf.ToList(); //rafs.MamulList = db.Kategori.ToList(); var rafss = db.RafUrun.Where(a => a.UrunID == id).ToList(); // var katss = db.KatUrun.Where(b => b.UrunID == id).ToList(); List <Raf> model = new List <Raf>(); foreach (var item in rafss) { Raf secilen = new Raf(); secilen.RafID = Convert.ToInt32(item.RafID); secilen.RafAdi = item.Raf.RafAdi; model.Add(secilen); } //List<Kategori> modelKat = new List<Kategori>(); //foreach (var item in katss) //{ // Kategori sec = new Kategori(); // sec.KategoriID = Convert.ToInt32(item.KategoriID); // sec.UrunAdi = item.Kategori.UrunAdi; // modelKat.Add(sec); //} //rafs.MamulM = modelKat; rafs.RafM = model; return(View(rafs)); } else { return(RedirectToAction("Giris", "Admin")); } }
public ActionResult Edit(Raflar raflar) { db.Entry(raflar).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Raflar")); }