Ejemplo n.º 1
0
 /// <summary>
 /// 创建一个实体
 /// </summary>
 /// <param name="entity">实体</param>
 /// <returns></returns>
 public int Create(Entity.SysSample entity)
 {
     using (DBContainer db = new DBContainer())
     {
         db.SysSample.AddObject(entity);
         return db.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 创建一个对象
 /// </summary>
 /// <param name="db">数据库</param>
 /// <param name="entity">实体</param>
 public int Create(SysLog entity)
 {
     using (DBContainer db = new DBContainer())
     {
         db.SysLog.AddObject(entity);
         return db.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 新增系统功能
 /// </summary>
 /// <param name="entity">系统功能</param>
 /// <returns></returns>
 public int CreateSysFunction(Entity.SysFunction entity)
 {
     using (DBContainer db = new DBContainer())
     {
         db.SysFunction.AddObject(entity);
         return db.SaveChanges();
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 创建菜单组
 /// </summary>
 /// <param name="entity">菜单组</param>
 /// <returns></returns>
 public int CreateMenuGroup(MenuGroup entity)
 {
     using (DBContainer db = new DBContainer())
     {
         db.MenuGroup.AddObject(entity);
         return db.SaveChanges();
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 更新一个实体
 /// </summary>
 /// <param name="entity">实体</param>
 /// <returns></returns>
 public int Edit(Entity.SysSample entity)
 {
     using (DBContainer db = new DBContainer())
     {
         db.SysSample.Attach(entity);
         db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
         return db.SaveChanges();
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 删除一个实体
 /// </summary>
 /// <param name="id">id</param>
 /// <returns></returns>
 public int Delete(string id)
 {
     using (DBContainer db = new DBContainer())
     {
         var entity = db.SysSample.SingleOrDefault(p => p.Id.Equals(id));
         if (entity != null)
         {
             db.SysSample.DeleteObject(entity);
         }
         return db.SaveChanges();
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 删除菜单组
        /// </summary>
        /// <param name="id">菜单组Id</param>
        /// <returns></returns>
        public int DeleteMenuGroup(string id)
        {
            using (DBContainer db = new DBContainer())
            {
                var entity = db.MenuGroup.SingleOrDefault(p => p.MenuGroup_Id.Equals(id, StringComparison.CurrentCultureIgnoreCase));

                if (entity != null)
                    db.MenuGroup.DeleteObject(entity);

                return db.SaveChanges();
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// 更新菜单组
 /// </summary>
 /// <param name="entity">菜单组</param>
 /// <returns></returns>
 public int EditMenuGroup(MenuGroup entity)
 {
     using (DBContainer db = new DBContainer())
     {
         db.MenuGroup.Attach(entity);
         db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
         return db.SaveChanges();
     }
 }