public ActionResult GetSkis(Narty nvm, Klienci avm) { List <Narty> liP = db.Narties.ToList(); ViewBag.categorylist = new SelectList(liP, "NartaId", "NartaProducent"); List <Narty> liM = db.Narties.ToList(); ViewBag.categorylist = new SelectList(liM, "NartaId", "NartaModel"); Narty nId = db.Narties.Where(x => x.NartaProducent == nvm.NartaProducent && x.NartaModel == nvm.NartaModel).SingleOrDefault(); if (nId != null) { Narty n = new Narty(); Transakcje t = new Transakcje(); t.NartaId = nId.NartaId; t.KlientId = Int32.Parse(Session["u_id"].ToString()); p.pro_price = pvm.pro_price; p.pro_image = path; p.pro_fk_cat = pvm.pro_fk_cat; p.pro_des = pvm.pro_des; p.pro_fk_user = Convert.ToInt32(Session["u_id"].ToString()); db.Transakcjes.Add(n); db.SaveChanges(); Response.Redirect("index"); } else { ViewBag.error = "Niepoprawne dane nart."; } return(View()); }
public ActionResult Create(Narty cvm, HttpPostedFileBase imgfile) { string path = uploadimgfile(imgfile); if (path.Equals("-1")) { ViewBag.error = "Nie udalo sie wczytac obrazka"; } else { Narty nar = new Narty(); nar.NartaProducent = cvm.NartaProducent; nar.NartaModel = cvm.NartaModel; nar.NartaCena = cvm.NartaCena; nar.NartaZdjecie = path; nar.NartaStatus = true; db.Narties.Add(nar); db.SaveChanges(); return(RedirectToAction("ViewNarty")); } return(View()); }