public static bool Update(AgamaViewModel model) { bool result = true; try { using (var db = new DB_UniversityEntities()) { tbl_m_agama attributs = db.tbl_m_agama.Where(o => o.id_agama_pk == model.id_agama_pk).FirstOrDefault(); if (attributs != null) { attributs.kode_agama = model.kode_agama; attributs.deskripsi = model.deskripsi; attributs.is_active = model.is_active; attributs.updated_by = model.updated_by; attributs.updated_date = model.updated_date; db.SaveChanges(); } else { result = false; Message = "Categories not found!"; } } } catch (Exception hasError) { Message = hasError.Message; result = false; } return(result); }
public static bool Insert(AgamaViewModel model) { bool result = true; try { using (var db = new DB_UniversityEntities()) { tbl_m_agama attributs = new tbl_m_agama(); attributs.deskripsi = model.deskripsi; attributs.is_active = model.is_active; attributs.created_by = model.created_by; attributs.created_date = model.created_date; attributs.updated_by = model.updated_by; attributs.updated_date = model.updated_date; attributs.kode_agama = model.kode_agama; db.tbl_m_agama.Add(attributs); db.SaveChanges(); } } catch (Exception hasError) { if (hasError.Message.ToLower().Contains("inner exception")) { Message = hasError.InnerException.InnerException.Message; } else { Message = hasError.Message; } result = false; } return(result); }