コード例 #1
0
        public static int InsertRuntimeSwitch(RuntimeSwitch model)
        {
            const string sql1 = @"SELECT  COUNT(0) FROM [Gungnir].[dbo].[RuntimeSwitch] WITH ( NOLOCK ) WHERE [SwitchName]=@SwitchName ";

            var sqlParam1 = new SqlParameter[]
            {
                new SqlParameter("@Switchname", model.SwitchName)
            };

            int count = (int)SqlHelper.ExecuteScalar(conn, CommandType.Text, sql1, sqlParam1);

            if (count > 0)
            {
                return(-1);
            }

            const string sql = @"INSERT INTO Gungnir..RuntimeSwitch
                                        (SwitchName, Value, Description, CreatedTime, UpdatedTime)
                                VALUES  (
                                         @SwitchName,
                                         @Value,
                                         @Description,
                                         GETDATE(),
                                         GETDATE()
                                         )";

            var sqlParam = new SqlParameter[]
            {
                new SqlParameter("@SwitchName", model.SwitchName),
                new SqlParameter("@Value", model.Value),
                new SqlParameter("@Description", model.Description)
            };

            return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, sqlParam));
        }
コード例 #2
0
 public ActionResult Add(RuntimeSwitch model)
 {
     if (model.PKID == 0)
     {
         return(View(new RuntimeSwitch()));
     }
     else
     {
         return(View(RuntimeSwitchManager.GetRuntimeSwitch(model.PKID)));
     }
 }
コード例 #3
0
        public static bool UpdateRuntimeSwitch(RuntimeSwitch model)
        {
            const string sql = @"UPDATE [Gungnir].[dbo].[RuntimeSwitch] SET Value=@Value,CreatedTime=GETDATE(),Description=@desc WHERE PKID=@Id";
            //const string sql = @"UPDATE [Gungnir].[dbo].[RuntimeSwitch] SET Value=@Value,UpdatedTime=GETDATE() WHERE PKID=@Id";
            var sqlParam = new SqlParameter[]
            {
                new SqlParameter("@Value", model.Value),
                new SqlParameter("@Id", model.PKID),
                new SqlParameter("@desc", model.Description)
            };

            return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, sqlParam) > 0);
        }
コード例 #4
0
 public int InsertRuntimeSwitch(RuntimeSwitch model)
 {
     try
     {
         return(DALRuntimeSwitch.InsertRuntimeSwitch(model));
     }
     catch (Exception ex)
     {
         var exception = new RuntimeSwitchException(1, "InsertRuntimeSwitch", ex);
         Logger.Log(Level.Error, exception, "InsertRuntimeSwitch");
         throw ex;
     }
 }
コード例 #5
0
 public JsonResult Insert(RuntimeSwitch model)
 {
     return(Json(RuntimeSwitchManager.InsertRuntimeSwitch(model)));
 }
コード例 #6
0
 public JsonResult Update(RuntimeSwitch model)
 {
     return(Json(RuntimeSwitchManager.UpdateRuntimeSwitch(model)));
 }