public IRestResponse checkPayments(GetPayments body) { RestClient restClient = new RestClient(_payments); RestRequest restRequest = new RestRequest("", Method.GET); restRequest.AddHeader("X-Application-Key", _apiKey); foreach (PropertyInfo prop in body.GetType().GetProperties()) { string param = ""; var type = Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType; if (type == typeof(string[])) { string[] status = (string[])prop.GetValue(body, null); for (int i = 0; i < status.Length; i++) { param += status[i] + ","; } // Remove trailing comma param = param.Substring(0, param.Length - 1); } else { param = prop.GetValue(body, null).ToString(); } restRequest.AddParameter(prop.Name, param, ParameterType.QueryString); } IRestResponse restResponse = restClient.Get(restRequest); return(restResponse); }
public ApiResponse <List <Payment> > GetPayments(GetPayments req) { var result = null as List <Payment>; using (var connection = new SqlConnection(_connectionString.HotelManagement)) { var cmd = new SqlCommand(p_Payments_Get, connection) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@UserID", _requestInfo.UserId); cmd.Parameters.Add("@RetVal", SqlDbType.Int).Direction = ParameterDirection.Output; cmd.Parameters.Add("@RetMsg", SqlDbType.VarChar, 500).Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@PaymentID", req.PaymentId); cmd.Parameters.AddWithValue("@GuestID", req.GuestId); cmd.Parameters.AddWithValue("@Amount", req.Amount); cmd.Parameters.AddWithValue("@CardTypeID", req.CardTypeId); cmd.Parameters.AddWithValue("@SafetyDeposit", req.SafetyDeposit); cmd.Parameters.AddWithValue("@Comment", req.Comment); connection.Open(); using (var dr = cmd.ExecuteReader()) { result = new List <Payment>(); while (dr.Read()) { result.Add(new Payment { PaymentId = dr["PaymentID"].ToSafeInt32(), GuestId = dr["GuestID"].ToSafeInt32(), Amount = dr["Amount"].ToSafeDecimal(), CardTypeId = dr["CardTypeID"].ToSafeInt32(), SafetyDeposit = dr["SafetyDeposit"].ToSafeDecimal(), Comment = dr["Comment"].ToSafeString(), CreatedId = dr["CreatedID"].ToSafeInt32(), CreatedBy = dr["CreatedBy"].ToSafeString(), CreatedDateTime = dr["CreatedDateTime"].ToSafeDateTime(), ModifiedId = dr["ModifiedID"].ToSafeInt32(), ModifiedBy = dr["ModifiedBy"].ToSafeString(), ModifiedDateTime = dr["ModifiedDateTime"].ToSafeDateTime() }); } } return(new ApiResponse <List <Payment> > { Content = result, Status = new ReturnStatus(cmd.Parameters["@RetVal"].Value.ToSafeInt32(), cmd.Parameters["@RetMsg"].Value.ToSafeString()) }); } }
private void _checkPayments() { GetPayments getPayments = new GetPayments(); getPayments.uuid = _uuid; getPayments.start = _start.ToString("yyyy-MM-dd"); getPayments.end = _end.ToString("yyyy-MM-dd"); Console.WriteLine($"Checking pamyents made between {getPayments.start} and {getPayments.end} \n"); KipleHomeService kipleHomeService = new KipleHomeService(); IRestResponse restResponse = kipleHomeService.checkPayments(getPayments); _constructList(restResponse); }
public List <Payment> GetPayments(GetPayments req) { return(null); }