public static List <VMMenu> GetListDropdown() { List <VMMenu> listData = new List <VMMenu>(); using (var db = new Markom_IDLEEntities()) { listData = (from a in db.m_menu where a.is_delete == false select new VMMenu { id = a.id, code = a.code, name = a.name, controller = a.controller, parent_id = a.parent_id, is_delete = a.is_delete, created_by = a.created_by, created_date = a.created_date, updated_by = a.updated_by, updated_date = a.updated_date }).ToList(); } return(listData); }
public static VMMenu GetDetailById(int Id) { VMMenu result = new VMMenu(); using (var db = new Markom_IDLEEntities()) { result = (from a in db.m_menu where a.id == Id select new VMMenu { id = a.id, code = a.code, name = a.name, controller = a.controller, parent_id = a.parent_id, is_delete = a.is_delete, created_by = a.created_by, created_date = a.created_date, updated_by = a.updated_by, updated_date = a.updated_date }).FirstOrDefault(); } return(result); }
public static bool Insert(VMMenu paramModel) { bool result = true; try { using (var db = new Markom_IDLEEntities()) { m_menu a = new m_menu(); a.code = paramModel.code; a.name = paramModel.name; a.controller = paramModel.controller; a.parent_id = paramModel.parent_id; a.is_delete = paramModel.is_delete; a.created_by = paramModel.created_by; a.created_date = paramModel.created_date; db.m_menu.Add(a); db.SaveChanges(); } } catch (Exception hasError) { result = false; if (hasError.Message.ToLower().Contains("inner exception")) { Message = hasError.InnerException.InnerException.Message; } else { Message = hasError.Message; } } return(result); }
public static bool Delete(VMMenu paramModel) { bool result = true; try { using (var db = new Markom_IDLEEntities()) { m_menu a = db.m_menu.Where(o => o.id == paramModel.id).FirstOrDefault(); if (a != null) { a.is_delete = true; db.SaveChanges(); } else { result = false; } } } catch (Exception hasError) { result = false; if (hasError.Message.ToLower().Contains("inner exception")) { Message = hasError.InnerException.InnerException.Message; } else { Message = hasError.Message; } } return(result); }
public static bool Insert(VMProduct paramModel) { bool result = true; try { using (var db = new Markom_IDLEEntities()) { m_product a = new m_product(); a.code = paramModel.code; a.name = paramModel.name; a.description = paramModel.description; a.is_delete = paramModel.is_delete; a.created_by = paramModel.created_by; a.created_date = paramModel.created_date; db.m_product.Add(a); db.SaveChanges(); } } catch (Exception hasError) { result = false; if (hasError.Message.ToLower().Contains("inner exception")) { Message = hasError.InnerException.InnerException.Message; } else { Message = hasError.Message; } } return(result); }
public static List <VMRole> GetListAll(string searchName, string searchCode, string searchDescription, DateTime?searchDate, string searchCreatedProduct) { List <VMRole> listData = new List <VMRole>(); using (var db = new Markom_IDLEEntities()) { listData = (from a in db.m_role where a.is_delete == false select new VMRole { id = a.id, code = a.code, name = a.name, description = a.description, is_delete = a.is_delete, created_by = a.created_by, created_date = a.created_date, updated_by = a.updated_by, updated_date = a.updated_date }).ToList(); } if (!string.IsNullOrEmpty(searchName)) { listData = listData.Where(x => x.name == searchName).ToList(); } if (!string.IsNullOrEmpty(searchCode)) { listData = listData.Where(x => x.code == searchCode).ToList(); } if (!string.IsNullOrEmpty(searchDescription)) { listData = listData.Where(x => x.description == searchDescription).ToList(); } if (searchDate != null) { listData = listData.Where(x => x.created_date.ToString("dd MMMM yyyy") == searchDate.Value.ToString("dd MMMM yyyy")).ToList(); } if (!string.IsNullOrEmpty(searchCreatedProduct)) { listData = listData.Where(x => x.created_by == searchCreatedProduct).ToList(); } if (listData.Count == 0) { DataKosong = "Data tidak ditemukan"; } else { DataKosong = ""; } return(listData); }
public ActionResult Create(VMMenu paramModel) { try { MenuRepo.Message = string.Empty; //Create auto generate product_code using (var db = new Markom_IDLEEntities()) { string nol = ""; m_menu cek = db.m_menu.OrderByDescending(x => x.code).First(); int simpan = int.Parse(cek.code.Substring(3)); simpan++; for (int i = simpan.ToString().Length; i < 4; i++) { nol = nol + "0"; } paramModel.code = "ME" + nol + simpan; } paramModel.created_by = "Administrator"; paramModel.created_date = DateTime.Now; paramModel.is_delete = false; if (null == paramModel.name) { MenuRepo.Message = "Anda belum memasukan semua data. Silahkan ulangi kembali"; } if (string.IsNullOrEmpty(MenuRepo.Message)) { return(Json(new { success = MenuRepo.Insert(paramModel), message = paramModel.code }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = MenuRepo.Message }, JsonRequestBehavior.AllowGet)); } } catch (Exception hasError) { return(Json(new { success = false, message = hasError.Message }, JsonRequestBehavior.AllowGet)); } }
public static bool Update(VMRole paramModel) { bool result = true; try { using (var db = new Markom_IDLEEntities()) { m_role a = db.m_role.Where(o => o.id == paramModel.id).FirstOrDefault(); if (a != null) { a.name = paramModel.name; a.description = paramModel.description; a.updated_by = paramModel.updated_by; a.updated_date = paramModel.updated_date; db.SaveChanges(); } else { result = false; } } } catch (Exception hasError) { result = false; if (hasError.Message.ToLower().Contains("inner exception")) { Message = hasError.InnerException.InnerException.Message; } else { Message = hasError.Message; } } return(result); }
public static VMRole GetDetailById(int Id) { VMRole result = new VMRole(); using (var db = new Markom_IDLEEntities()) { result = (from a in db.m_role where a.id == Id select new VMRole { id = a.id, code = a.code, name = a.name, description = a.description, is_delete = a.is_delete, created_by = a.created_by, created_date = a.created_date, updated_by = a.updated_by, updated_date = a.updated_date }).FirstOrDefault(); } return(result); }