예제 #1
0
 public void UpdateClientInfo(ClientInfo clientInfo)
 {
     var sqlStatement = string.Format("UPDATE ServiceClient SET clientid = '{0}', clientsecret = '{1}', description = '{2}' WHERE id = {3} ",
        clientInfo.ClientId, clientInfo.ClientSecret,clientInfo.Description,clientInfo.Id);
     try
     {
         _sqlDataAccess.ExecuteNonQuery(sqlStatement);
     }
     catch (Exception e)
     {
         // log error
         throw;
     }
 }
예제 #2
0
        public IHttpActionResult SaveClient(ClientInfo clientInfo)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var isInsert = clientInfo.Id == 0;
                    clientInfo.ClientSecret = Crypto.HashPassword(clientInfo.ClientSecret);
                    if (isInsert)
                    {
                        _dbService.AddClientInfo(clientInfo);
                    }
                    else
                    {
                        _dbService.UpdateClientInfo(clientInfo);
                    }
                    return Ok(new ResponseData<ClientInfo> { Data = new List<ClientInfo> { clientInfo }, Done = true });

                }
                catch (Exception ex)
                {
                    return Ok(new ResponseData<ClientInfo> { Data = null, Done = false, Message = ex.Message });

                }
            }
            return Ok(new ResponseData<ClientInfo> { Data = null, Done = false, Message = "Model invalid" });


        }
예제 #3
0
 public void AddClientInfo(ClientInfo clientInfo)
 {
     var sqlStatement = string.Format("INSERT INTO ServiceClient (clientid, clientsecret, description) VALUES ('{0}','{1}','{2}')",
         clientInfo.ClientId, clientInfo.ClientSecret,clientInfo.Description);
     try
     {
         _sqlDataAccess.ExecuteNonQuery(sqlStatement);
     }
     catch (Exception e)
     {
         // log error
         throw;
     }
 }