public ActionResult Create(tbl_genders type) { var tbl_genders = new tbl_genders(); var dic = new Dictionary <string, string>(); foreach (string lang in BLL.GlobalData.Languages) { dic.Add(lang, Request.Form["name[" + lang + "]"]); } tbl_genders.name = JsonConvert.SerializeObject(dic); db.tbl_genders.Add(tbl_genders); db.SaveChanges(); if (Request.IsAjaxRequest()) { var res = new { type = "success", message = "Save Success" }; return(Json(res)); } return(RedirectToAction("Index")); //if (Request.IsAjaxRequest()) //{ // var res = new { type = "error", message = "Error while save !" }; // return Json(res); //} //return View(tbl_genders); }
public ActionResult Edit([Bind(Include = "Name,id")] tbl_genders type) { var tbl_genders = new tbl_genders(); var dic = new Dictionary <string, string>(); foreach (string lang in BLL.GlobalData.Languages) { dic.Add(lang, Request.Form["name[" + lang + "]"]); } //dic.Add("ar", Request.Form["name[ar]"]); tbl_genders.name = JsonConvert.SerializeObject(dic); tbl_genders.id = int.Parse(Request.Form["id"]); db.Entry(tbl_genders).State = EntityState.Modified; db.SaveChanges(); if (Request.IsAjaxRequest()) { var res = new { type = "success", message = "Save Success" }; return(Json(res)); } return(RedirectToAction("Index")); if (Request.IsAjaxRequest()) { var res = new { type = "error", message = "Error while save !" }; return(Json(res)); } return(View(tbl_genders)); }
public ActionResult DeleteConfirmed(int id) { tbl_genders tbl_genders = db.tbl_genders.Find(id); db.tbl_genders.Remove(tbl_genders); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "id,name")] tbl_genders tbl_genders) { if (ModelState.IsValid) { db.Entry(tbl_genders).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbl_genders)); }
public ActionResult Create([Bind(Include = "id,name")] tbl_genders tbl_genders) { if (ModelState.IsValid) { db.tbl_genders.Add(tbl_genders); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbl_genders)); }
public ActionResult DeleteConfirmed(int id) { tbl_genders tbl_genders = db.tbl_genders.Find(id); db.tbl_genders.Remove(tbl_genders); db.SaveChanges(); if (Request.IsAjaxRequest()) { var res = new { type = "success", message = "Deleted Success" }; return(Json(res)); } return(RedirectToAction("Index")); }
// GET: Addreesees/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tbl_genders tbl_genders = db.tbl_genders.Find(id); if (tbl_genders == null) { return(HttpNotFound()); } return(View(tbl_genders)); }