public static bool Delete(DosenViewModel model) { bool result = true; try { using (var db = new DB_UniversityEntities()) { tbl_m_dosen attributs = db.tbl_m_dosen.Where(o => o.id_dosen_pk == model.id_dosen_pk).FirstOrDefault(); if (attributs != null) { 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(DosenViewModel model) { bool result = true; try { using (var db = new DB_UniversityEntities()) { tbl_m_dosen attributs = new tbl_m_dosen(); attributs.nama_dosen = model.nama_dosen; attributs.id_jurusan_fk = model.id_jurusan_fk; attributs.id_type_dosen_fk = model.id_type_dosen_fk; 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_dosen = model.kode_dosen; db.tbl_m_dosen.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); }