public ActionResult DeleteConfirmed(int id, audit_trail audit) { var check = db.clients.Where(s => s.Client_Type_ID == id).FirstOrDefault(); if (check == null) { client_type client_type = db.client_type.Find(id); var userId = System.Web.HttpContext.Current.Session["UserID"] as String; int IntID = Convert.ToInt32(userId); audit.Employee_ID = IntID; audit.Trail_DateTime = DateTime.Now.Date; audit.Deleted_Record = client_type.Client_Type_ID.ToString() + " " + client_type.Client_Type_Name + " " + client_type.Client_Type_Description; audit.Trail_Description = "Deleted a Client Type"; db.audit_trail.Add(audit); db.client_type.Remove(client_type); db.SaveChanges(); return(RedirectToAction("Index")); } else { client_type client_type = db.client_type.Find(id); ViewBag.Error = "Can't delete a type that is in-use please add a new type instead, or delete all clients related to this type first."; return(View(client_type)); } }
public ActionResult DeleteConfirmed(int id) { client_type client_type = db.client_type.Find(id); db.client_type.Remove(client_type); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Client_Type_ID,Client_Type_Name,Client_Type_Description")] client_type client_type) { if (ModelState.IsValid) { db.Entry(client_type).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(client_type)); }
public ActionResult Create([Bind(Include = "Client_Type_ID,Client_Type_Name,Client_Type_Description")] client_type client_type) { if (ModelState.IsValid) { db.client_type.Add(client_type); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(client_type)); }
// GET: client_type/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } client_type client_type = db.client_type.Find(id); if (client_type == null) { return(HttpNotFound()); } return(View(client_type)); }
public JsonResult delete_type(int id) { try { client_type t = DB.client_type.Where(x => x.id == id).Single(); DB.client_type.Remove(t); DB.SaveChanges(); return(Json(new { msg = "تمت عمليه الحذف بنجاح" })); } catch { return(Json(new { msg = "لم تتم عمليه الحذف .. حاول مره اخري" })); } }
public JsonResult add_type(string type) { try { client_type t = new client_type(); t.type = type; DB.client_type.Add(t); DB.SaveChanges(); return(Json(new { msg = "تمت عمليه الاضافه بنجاح" })); }catch { return(Json(new { msg = "لم تتم عمليه الاضافه..حاول مره اخري" })); } }
public JsonResult update_type(int id, string type) { try { client_type t = DB.client_type.Where(x => x.id == id).Single(); t.type = type; DB.Entry(t).State = EntityState.Modified; DB.SaveChanges(); return(Json(new { msg = "تمت عمليه التعديل بنجاح" })); } catch { return(Json(new { msg = "لم تتم عمليه التعديل..حاول مره اخري" })); } }
public ActionResult Edit([Bind(Include = "Client_Type_ID,Client_Type_Name,Client_Type_Description")] client_type client_type) { bool val = db.client_type.Any(s => s.Client_Type_Name == client_type.Client_Type_Name && s.Client_Type_ID != client_type.Client_Type_ID); if (ModelState.IsValid && val == false) { db.Entry(client_type).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else if (val == true) { ViewBag.StatusMessage = "There is already an: " + client_type.Client_Type_Name + " type in the database."; return(View()); } return(View(client_type)); }
public ActionResult Create([Bind(Include = "Client_Type_ID,Client_Type_Name,Client_Type_Description")] client_type client_type) { bool val = Validate(client_type.Client_Type_Name); if (ModelState.IsValid && val == false) { db.client_type.Add(client_type); db.SaveChanges(); return(RedirectToAction("Index")); } else if (val == true) { ViewBag.StatusMessage = "There is already an: " + client_type.Client_Type_Name + " type in the database."; return(View()); } return(View(client_type)); }