Exemple #1
0
        public async Task <IActionResult> PostRechargeTransaction([FromBody] RechargeTransaction rechargeTransaction)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.RechargeTransactions.Add(rechargeTransaction);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetRechargeTransaction", new { id = rechargeTransaction.Id }, rechargeTransaction));
        }
Exemple #2
0
        //static readonly HttpClient client = new HttpClient();

        public static CreditSwitchRequest GetRequest(RechargeTransaction trans, CreditSwitchConfig config)
        {
            long   amt      = Convert.ToInt64(trans.Amount);
            string checkSum = Utility.CheckSum(config.MerchantId, trans.TransactionId, trans.ServiceCode, amt, config.PrivateKey, trans.PhoneNumber);

            CreditSwitchRequest req = new CreditSwitchRequest
            {
                LoginId   = config.MerchantId,
                Key       = config.PublicKey,
                RequestId = trans.TransactionId,
                ServiceId = trans.ServiceCode,
                Amount    = amt,
                Recipient = trans.PhoneNumber,
                Date      = DateTime.Now.ToUniversalTime().ToString("dd-MMM-yyyy hh:mm 'GMT'"),
                Checksum  = checkSum
            };

            return(req);
        }
Exemple #3
0
        public async Task <List <RechargeTransaction> > FetchTransactionHistory(int userID, string startDate, string endDate)
        {
            List <RechargeTransaction> transactions = new List <RechargeTransaction>();

            using (SqlConnection connection = new SqlConnection(this._connectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand("FETCH_TRANSACTION_HISTORY", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@userID", SqlDbType.Int).Value     = userID;
                    command.Parameters.Add("@startDate", SqlDbType.Date).Value = Convert.ToDateTime(startDate).Date;
                    command.Parameters.Add("@endDate", SqlDbType.Date).Value   = Convert.ToDateTime(endDate).Date.AddDays(1);

                    try
                    {
                        using (SqlDataReader reader = await command.ExecuteReaderAsync())
                        {
                            while (reader.Read())
                            {
                                var transaction = new RechargeTransaction
                                {
                                    TransactionID      = Convert.ToInt32(reader["transaction_id"].ToString()),
                                    UserID             = Convert.ToInt32(reader["userID"].ToString()),
                                    TransactionDate    = Convert.ToDateTime(reader["transactionDate"].ToString()),
                                    TransactionMode    = reader["rechargeMode"].ToString(),
                                    TransactionStatus  = reader["transactionStatus"].ToString(),
                                    TransactionMessage = reader["errorMessage"].ToString(),
                                    TransactionAmount  = Convert.ToDecimal(reader["rechargeAmount"].ToString()),
                                    ServiceNumber      = reader["service_number"].ToString()
                                };
                                transactions.Add(transaction);
                            }
                        }
                        return(transactions = transactions.OrderByDescending(o => o.TransactionDate).ToList());
                    }
                    catch (Exception ex)
                    {
                        return(null);
                    }
                }
            }
        }
        public static RechargeTransaction GetTransaction(VendRequest request, RechargeType type, string serviceCode)
        {
            if (request == null)
            {
                return(null);
            }

            RechargeTransaction transaction = new RechargeTransaction
            {
                Amount        = request.Amount,
                DealerCode    = request.DealerCode,
                PhoneNumber   = request.PhoneNumber,
                RechargeType  = type,
                RequestType   = RequestType.Request,
                ServiceCode   = serviceCode,
                Status        = TransactionStatus.INITIATED,
                TransactionId = Utility.GetRequestId(),
                TransDate     = DateTime.Now
            };

            return(transaction);
        }
        public static RechargeTransaction GetTransaction(CreditSwitchRespose resp, CreditSwitchRequest req, RechargeType type)
        {
            if (resp == null)
            {
                return(null);
            }

            RechargeTransaction transaction = new RechargeTransaction
            {
                Amount              = Convert.ToDouble(resp.Amount == 0 ? req.Amount : resp.Amount),
                ResponseCode        = resp.StatusCode,
                ResponseDescription = resp.StatusDescription,
                TransactionId       = String.IsNullOrWhiteSpace(resp.MReference) ? req.RequestId : resp.MReference,
                Reference           = resp.TranxReference,
                PhoneNumber         = String.IsNullOrWhiteSpace(resp.Recipient) ? req.Recipient : resp.Recipient,
                ConfirmCode         = resp.ConfirmCode,
                TransDate           = resp.TranxDate,
                RechargeType        = type,
                RequestType         = RequestType.Response,
                Status              = resp.StatusCode == "00" ? TransactionStatus.SUCCESSFUL : TransactionStatus.FAILED
            };

            return(transaction);
        }
Exemple #6
0
        public async Task <IActionResult> PutRechargeTransaction([FromRoute] long id, [FromBody] RechargeTransaction rechargeTransaction)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != rechargeTransaction.Id)
            {
                return(BadRequest());
            }

            _context.Entry(rechargeTransaction).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RechargeTransactionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #7
0
        public async Task <List <Complaint> > FetchUserComplaintAdmin()
        {
            List <Complaint> complaints = new List <Complaint>();

            using (SqlConnection connection = new SqlConnection(this._connectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand("FETCH_USER_COMPLAINT_ADMIN", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    try
                    {
                        using (SqlDataReader reader = await command.ExecuteReaderAsync())
                        {
                            while (reader.Read())
                            {
                                var complaint = new Complaint
                                {
                                    CID               = Convert.ToInt32(reader["cid"].ToString()),
                                    RaisedBy          = Convert.ToInt32(reader["raisedby"].ToString()),
                                    RaisedByText      = reader["raisedBy"].ToString(),
                                    TID               = Convert.ToInt32(reader["tid"].ToString()),
                                    CPriority         = Convert.ToInt32(reader["cpriority"].ToString()),
                                    UserContactNumber = reader["user_contact"].ToString(),
                                    UserComment       = reader["user_comment"].ToString(),
                                    CStatus           = Convert.ToInt32(reader["cstatus"].ToString()),
                                    ResolverComment   = reader["resolver_comment"].ToString(),
                                    AssignedToName    = reader["user_name"].ToString(),
                                };
                                var transaction = new RechargeTransaction
                                {
                                    TransactionMessage = reader["errorMessage"].ToString(),
                                    TransactionAmount  = Convert.ToDecimal(reader["rechargeAmount"].ToString()),
                                    TransactionDate    = Convert.ToDateTime(reader["transactionDate"].ToString()).Date,
                                    TransactionMode    = reader["rechargeMode"].ToString(),
                                    TransactionStatus  = reader["transactionStatus"].ToString()
                                };
                                complaint.Transaction = transaction;
                                switch (Convert.ToInt32(reader["cpriority"].ToString()))
                                {
                                case 1:
                                    complaint.CPriorityText = "Low";
                                    break;

                                case 2:
                                    complaint.CPriorityText = "Medium";
                                    break;

                                case 3:
                                    complaint.CPriorityText = "High";
                                    break;
                                }
                                switch (Convert.ToInt32(reader["cstatus"].ToString()))
                                {
                                case 1:
                                    complaint.CStatusText = "Acknowledged";
                                    break;

                                case 2:
                                    complaint.CStatusText = "Assigned";
                                    break;

                                case 3:
                                    complaint.CStatusText = "Work In Progress";
                                    break;

                                case 4:
                                    complaint.CStatusText = "Resolved";
                                    break;
                                }
                                complaints.Add(complaint);
                            }
                        }
                        return(complaints);
                    }
                    catch (Exception ex)
                    {
                        return(null);
                    }
                }
            }
        }