LastHistoryItem IHistoryDAO.GetLastHistoryItem(String MerchantID, long TransactionID)
        {
            LastHistoryItem Results = new LastHistoryItem();

            Results.LastItem     = new CardHistory();
            Results.ResponseCode = 'E';
            Results.ErrorCode    = "MIDER"; // - merchant id error

            using (var GiftEntity = new GiftEntities())
            {
                // start by validating the merchant id

                Merchant Merch = GiftEntity.Merchants.FirstOrDefault(d => d.MerchantID == MerchantID);
                if (Merch == null)
                {
                    return(Results);
                }

                // get the last history item

                History LastHistory;
                if (TransactionID != 0L)
                {
                    LastHistory = (from h in GiftEntity.Histories
                                   where h.WhichMerchantGUID == Merch.MerchantGUID &&
                                   h.ErrorCode == "APP  " &&
                                   h.ID == TransactionID
                                   select h).FirstOrDefault();
                }
                else
                {
                    LastHistory = (from h in GiftEntity.Histories
                                   where h.WhichMerchantGUID == Merch.MerchantGUID &&
                                   h.ErrorCode == "APP  "
                                   orderby h.ID descending
                                   select h).FirstOrDefault();
                }
                if (LastHistory == null)
                {
                    Results.ErrorCode = "NOTRN";
                    return(Results);
                }

                // get the rest of the information

                Results.LastItem.CardNumber = (from c in GiftEntity.Cards
                                               where c.CardGUID == LastHistory.CardGUID
                                               select c.CardNumLast4).FirstOrDefault();
                Results.LastItem.TransType   = LastHistory.TransType;
                Results.LastItem.Transaction = ConvertTransactionType(LastHistory.TransType);
                Results.LastItem.When        = LastHistory.WhenHappened;
                Results.LastItem.Amount      = LastHistory.Amount;
                Results.LastItem.Text        = LastHistory.TransactionText;
                Results.ResponseCode         = 'A';
            }
            return(Results);
        }
Esempio n. 2
0
        ReceiptInformation ITransactionService.LastTransaction(String MerchantID, long TransactionID)
        {
            ReceiptInformation Results = new ReceiptInformation();
            IHistoryDAO        TransactionHistoryRepository = new HistoryDAO();
            LastHistoryItem    LastHistory = TransactionHistoryRepository.GetLastHistoryItem(MerchantID, TransactionID);

            if (LastHistory.ResponseCode != 'A')
            {
                Results.ErrorCode = LastHistory.ErrorCode;
                return(Results);
            }
            Results.TransactionType = LastHistory.LastItem.Transaction;
            Results.When            = LastHistory.LastItem.When;
            Results.CardNumber      = "XXXXXXXXXXXXX" + LastHistory.LastItem.CardNumber;
            Results.Amount          = LastHistory.LastItem.Amount;
            Results.Description     = LastHistory.LastItem.Text;
            return(Results);
        }