public ActionResult DeleteConfirmed(int id) { ms_currency ms_currency = db.ms_currency.Find(id); db.ms_currency.Remove(ms_currency); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "currency_id,currency_code,currency_name,fl_active,created_date,created_by,updated_date,updated_by,deleted_date,deleted_by,org_id")] ms_currency ms_currency) { if (ModelState.IsValid) { db.Entry(ms_currency).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ms_currency)); }
public ActionResult Create([Bind(Include = "currency_id,currency_code,currency_name,fl_active,created_date,created_by,updated_date,updated_by,deleted_date,deleted_by,org_id")] ms_currency ms_currency) { if (ModelState.IsValid) { db.ms_currency.Add(ms_currency); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ms_currency)); }
// GET: currency/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ms_currency ms_currency = db.ms_currency.Find(id); if (ms_currency == null) { return(HttpNotFound()); } return(View(ms_currency)); }
public JsonResult CrudCurrency() { if (UserProfile.UserId != 0) { if (Request.Form["oper"] == "add") { //prepare for insert data ms_currency cur = new ms_currency(); cur.currency_code = Request.Form["currency_code"]; cur.currency_name = Request.Form["currency_name"]; cur.fl_active = Request.Form["rec_isactive"] == "Yes" ? true : false; cur.created_by = UserProfile.UserId; cur.created_date = DateTime.Now; cur.updated_by = UserProfile.UserId; cur.updated_date = DateTime.Now; cur.org_id = UserProfile.OrgId; cur.deleted_by = null; cur.deleted_date = null; db.Entry(cur).State = EntityState.Added; db.SaveChanges(); return(Json("Insert", JsonRequestBehavior.AllowGet)); } else if (Request.Form["oper"] == "edit") { if (IsNumeric(Request.Form["currency_id"].ToString())) { //prepare for update data int id = Convert.ToInt32(Request.Form["currency_id"]); ms_currency cur = db.ms_currency.Find(id); cur.currency_code = Request.Form["currency_code"]; cur.currency_name = Request.Form["currency_name"]; cur.fl_active = Request.Form["rec_isactive"] == "Yes" ? true : false; cur.updated_by = UserProfile.UserId; cur.updated_date = DateTime.Now; db.Entry(cur).State = EntityState.Modified; db.SaveChanges(); return(Json("Update", JsonRequestBehavior.AllowGet)); } else { //prepare for insert data ms_currency cur = new ms_currency(); cur.currency_code = Request.Form["currency_code"]; cur.currency_name = Request.Form["currency_name"]; cur.fl_active = Request.Form["rec_isactive"] == "Yes" ? true : false; cur.created_by = UserProfile.UserId; cur.created_date = DateTime.Now; cur.updated_by = UserProfile.UserId; cur.updated_date = DateTime.Now; cur.org_id = UserProfile.OrgId; cur.deleted_by = null; cur.deleted_date = null; db.Entry(cur).State = EntityState.Added; db.SaveChanges(); return(Json("Insert", JsonRequestBehavior.AllowGet)); } } else { if (Request.Form["oper"] == "del") { //for delete process string ids = Request.Form["id"]; string[] values = ids.Split(','); for (int i = 0; i < values.Length; i++) { values[i] = values[i].Trim(); //prepare for soft delete data int id = Convert.ToInt32(values[i]); ms_currency cur = db.ms_currency.Find(id); cur.fl_active = false; cur.deleted_by = UserProfile.UserId; cur.deleted_date = DateTime.Now; db.Entry(cur).State = EntityState.Modified; db.SaveChanges(); } return(Json("Delete", JsonRequestBehavior.AllowGet)); } else { return(Json("Error", JsonRequestBehavior.AllowGet)); } } } else { return(Json("Session", JsonRequestBehavior.AllowGet)); } }