public ActionResult Create(Ilan ilan, int KategoriId,int Tip) { ViewBag.KategoriId = new SelectList(db.Kategoris, "KategoriId", "KategoriAdi"); List<SelectListItem> items = new List<SelectListItem>(); items.Add(new SelectListItem { Text = "Açık İhale", Value = "0" }); items.Add(new SelectListItem { Text = "Kapalı İhale", Value = "1" }); ViewBag.Tip = items; if (ModelState.IsValid) { string a = HttpContext.User.Identity.Name; var uye = (from z in db.Uyes where z.Mail == a select z).FirstOrDefault(); if (uye == null) { ModelState.AddModelError(string.Empty, "Teklif Vermeye yetkiniz yok"); } else { ilan.UyeId = uye.UyeId; ilan.IlanTuru = Convert.ToBoolean(Tip); ilan.KategoriId =(byte)KategoriId; db.Ilans.Add(ilan); db.SaveChanges(); return RedirectToAction("Index","Home"); } } return View(ilan); }
public ActionResult Create(Ilan ilan) { if (ModelState.IsValid) { db.Ilans.Add(ilan); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.UyeId = new SelectList(db.Uyes, "UyeId", "Ad", ilan.UyeId); ViewBag.KategoriId = new SelectList(db.Kategoris, "KategoriId", "KategoriAdi", ilan.KategoriId); return View(ilan); }
public ActionResult Edit(Ilan ilan) { if (ModelState.IsValid) { db.Entry(ilan).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.UyeId = new SelectList(db.Uyes, "UyeId", "Ad", ilan.UyeId); ViewBag.KategoriId = new SelectList(db.Kategoris, "KategoriId", "KategoriAdi", ilan.KategoriId); return View(ilan); }