/// <summary>
 /// 创建一个实体
 /// </summary>
 /// <param name="entity">实体</param>
 /// <returns></returns>
 public bool Create(SysOperationModel model)
 {
     try
     {
         SysOperations entity = operationsRepository.GetEntityById(model.Id);
         if (entity != null)
         {
             return(false);
         }
         entity               = new SysOperations();
         entity.Id            = model.Id;
         entity.OperationName = model.OperationName;
         entity.Code          = model.Code;
         entity.Icon          = model.Icon;
         entity.Sort          = model.Sort;
         entity.Description   = model.Description;
         entity.IsDelete      = model.IsDelete;
         entity.Created       = model.Created;
         entity.Creator       = model.Creator;
         if (operationsRepository.Create(entity) == 1)//成功
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #2
0
 /// <summary>
 /// 创建一个实体
 /// </summary>
 /// <param name="entity">实体</param>
 /// <returns></returns>
 public int Create(SysOperations entity)
 {
     using (DBContainer db = new DBContainer())
     {
         db.Set <SysOperations>().Add(entity);
         return(db.SaveChanges());
     }
 }
Beispiel #3
0
 /// <summary>
 /// 删除一个实体
 /// </summary>
 /// <param name="entity">实体</param>
 /// <returns></returns>
 public int Delete(int id)
 {
     using (DBContainer db = new DBContainer())
     {
         SysOperations entity = db.SysOperations.SingleOrDefault(x => x.Id == id);
         db.Set <SysOperations>().Remove(entity);
         return(db.SaveChanges());
     }
 }
Beispiel #4
0
 /// <summary>
 /// 修改一个实体
 /// </summary>
 /// <param name="entity">实体</param>
 /// <returns></returns>
 public int Edit(SysOperations entity)
 {
     using (DBContainer db = new DBContainer())
     {
         db.Set <SysOperations>().Attach(entity);
         db.Entry <SysOperations>(entity).State = EntityState.Modified;
         return(db.SaveChanges());
     }
 }
Beispiel #5
0
 /// <summary>
 /// 判断一个实体是否存在
 ///
 /// </summary>
 /// <param name="id">id</param>
 /// <returns>是否存在 true or false</returns>
 public bool IsExist(int id)
 {
     using (DBContainer db = new DBContainer())
     {
         SysOperations entity = db.SysOperations.SingleOrDefault(model => model.Id == id);
         if (entity != null)
         {
             return(true);
         }
         return(false);
     }
 }
        /// <summary>
        /// 获取一个实体
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public SysOperationModel GetEntityById(int id)
        {
            SysOperations     entity = operationsRepository.GetEntityById(id);
            SysOperationModel model  = new SysOperationModel();

            model.Id            = entity.Id;
            model.OperationName = entity.OperationName;
            model.Code          = entity.Code;
            model.Icon          = entity.Icon;
            model.Sort          = entity.Sort;
            model.Description   = entity.Description;
            model.IsDelete      = entity.IsDelete;
            model.Created       = entity.Created;
            model.Creator       = entity.Creator;
            return(model);
        }