Example #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;
     }
 }
        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" });


        }
Example #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;
     }
 }