コード例 #1
0
 public int AddSceneType(SceneTypeDto sceneType)
 {
     try
     {
         if (string.IsNullOrEmpty(sceneType.EnterpriseID))
         {
             throw new KnownException("企业ID不允许为空");
         }
         using (var db = new BCEnterpriseContext())
         {
             SceneType temp = new SceneType()
             {
                 Available    = sceneType.Available,
                 ID           = sceneType.ID,
                 EnterpriseID = sceneType.EnterpriseID,
                 Name         = sceneType.Name,
                 ParentID     = sceneType.ParentID
             };
             db.SceneTypes.Add(temp);
             if (0 < db.SaveChanges())
             {
                 return(temp.ID);
             }
             else
             {
                 return(-1);
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
コード例 #2
0
 public bool UpdateSceneType(SceneTypeDto sceneType)
 {
     try
     {
         if (string.IsNullOrEmpty(sceneType.EnterpriseID))
         {
             throw new KnownException("企业ID不允许为空");
         }
         using (var db = new BCEnterpriseContext())
         {
             var temp = db.SceneTypes.FirstOrDefault(x => x.ID == sceneType.ID);
             temp.Name         = sceneType.Name;
             temp.EnterpriseID = sceneType.EnterpriseID;
             temp.ParentID     = sceneType.ParentID;
             temp.Available    = sceneType.Available;
             return(0 < db.SaveChanges());
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }