/// <summary> /// 删除指定id的数据 /// </summary> /// <param name="id"></param> /// <returns></returns> public bool Remove(int id) { bool r = false; Models.CmRole obj = GetModel(id); db.CmRole.Remove(obj); r = db.SaveChanges() > 0; return(r); }
/// <summary> /// 根据模型到数据库 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Update(Models.CmRole model) { bool r = false; Models.CmRole obj = GetModel(model.Id); obj.Name = model.Name; obj.Rank = model.Rank; r = db.SaveChanges() > 0; return(r); }
/// <summary> /// 添加保持 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Add(Models.CmRole model) { int r = -1; if (!Exists(model)) { db.CmRole.Add(model); db.SaveChanges(); r = db.CmRole.Count(); } return(r); }
/// <summary> /// 判断是否存在 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Exists(Models.CmRole model) { return(db.CmRole.Contains(model)); }