public ActionResult Edit([Bind(Include = "id,latitude,longitude,email,name,phoneNumber,ImageName")] seller seller) { if (ModelState.IsValid) { db.Entry(seller).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(seller)); }
public ActionResult Create([Bind(Include = "id,libelle,MarquecategorieProd")] souscategorie souscategorie) { if (ModelState.IsValid) { db.souscategories.Add(souscategorie); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(souscategorie)); }
public ActionResult Create([Bind(Include = "Reference,Description,Marque,Modele,Name,Photo,Quantity,Color,Size,price,sousCategorieProdId,userId")] product product, HttpPostedFileBase File) { if (ModelState.IsValid) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Config.URL + "badword"); request.Method = "POST"; request.Headers.Add("text", product.Description); using (var reader = new StreamReader(request.GetResponse().GetResponseStream(), Encoding.UTF8)) { string responsetext = reader.ReadToEnd(); MessageResponse msg = JsonConvert.DeserializeObject <MessageResponse>(responsetext); if (msg.Code == 0) { if (File.ContentLength > 0) { string _FileName = Path.GetFileName(new Random().Next().ToString() + File.FileName); var path = Path.Combine(Server.MapPath("~/Content/Upload"), _FileName); File.SaveAs(path); product.Photo = _FileName; } user u = (user)Session["user"]; product.userId = u.id; db.product.Add(product); db.SaveChanges(); return(RedirectToAction("Index")); } else { List <string> badworsList = JsonConvert.DeserializeObject <List <string> >(msg.Message.ToString()); return(RedirectToAction("Create", new { msg = JsonConvert.SerializeObject(badworsList) })); } } } ViewBag.sousCategorieProdId = new SelectList(db.souscategories, "Id", "Libelle", product.sousCategorieProdId); return(View(product)); }
public void Commit() { dataContext.SaveChanges(); }