List <CardHistory> IHistoryDAO.GetCardHistory(String CardToSearchFor)
        {
            using (var GiftEntity = new GiftEntities())
            {
                List <CardHistory> Histories = new List <CardHistory>();
                ICardRepository    CardData  = new CardRepository(GiftEntity);
                Card WhichCard = CardData.GetCard(CardToSearchFor);
                if (WhichCard == null)
                {
                    return(Histories);
                }
                var CardHistories = from c in GiftEntity.Histories
                                                                           //join c2 in GiftEntity.Cards on c.Card2 equals c2.ID
                                    where c.CardGUID == WhichCard.CardGUID //||
                                                                           //c.Card2 == WhichCard.ID
                                    select new
                {
                    ID         = c.ID,
                    CardGUID   = c.CardGUID,
                    TransType  = c.TransType,
                    When       = c.WhenHappened,
                    Amount     = c.Amount,
                    MerchWhere = c.WhichMerchantGUID,
                    Clrk       = c.Clerk,
                    Text       = c.TransactionText,
                    //Card2 = c2.CardNumber,
                    InvoiceNumber = c.InvoiceNumber
                };

                // need to restructure what we return to the calling program
                if (CardHistories == null)
                {
                    return(Histories);
                }

                foreach (var Hist in CardHistories)
                {
                    string CardNumber = (from c in GiftEntity.Cards
                                         where c.CardGUID == Hist.CardGUID
                                         orderby c.ID descending
                                         select c.CardNumLast4).FirstOrDefault();
                    CardHistory Chist = new CardHistory();
                    Chist.ID         = Hist.ID;
                    Chist.CardNumber = CardNumber;
                    Chist.MerchWhere = (from m in GiftEntity.Merchants
                                        where m.MerchantGUID == Hist.MerchWhere
                                        select m.MerchantName).FirstOrDefault();
                    Chist.Clerk       = Hist.Clrk;
                    Chist.When        = Hist.When;
                    Chist.TransType   = Hist.TransType;
                    Chist.Transaction = ConvertTransactionType(Hist.TransType);
                    Chist.Amount      = Hist.Amount;
                    Chist.Text        = Hist.Text;
                    //Chist.Card2 = Hist.Card2;
                    Chist.InvoiceNumber = Hist.InvoiceNumber;
                    Histories.Add(Chist);
                }
                return(Histories);
            }
        }
Esempio n. 2
0
        void ICardHolderService.RegisterNewCard(String CardHolderName, String CardNumber)
        {
            using (GiftEntities GiftEntity = new GiftEntities())
            {
                ICardHolderRepository tCardHolderRepository = new CardHolderRepository(GiftEntity);
                ICardRepository       tCardRespository      = new CardRepository(GiftEntity);
                Card tCard = tCardRespository.GetCard(CardNumber);
                if (tCard == null)
                {
                    throw new Exception("Card not on file");
                }
                if (tCard.Activated != "Y")
                {
                    throw new Exception("Card not activated yet");
                }
                if (tCard.CardHolderGUID != null)
                {
                    throw new Exception("Card already registered to someone else");
                }

                CardHolder tCardHolder = tCardHolderRepository.RegisterThisCard(CardHolderName, tCard.CardGUID);
                if (tCardHolder != null)
                {
                    tCardRespository.RegisterCard(tCardHolder.ID, tCardHolder.CardHolderGUID, CardNumber);
                }
            }
        }
Esempio n. 3
0
 void ICardHolderService.UnregisterCard(String CardHolderName, String IDstr)
 {
     using (GiftEntities GiftEntity = new GiftEntities())
     {
         ICardHolderRepository tCardHolderRepository = new CardHolderRepository(GiftEntity);
         CardHolder            DBCardHolder          = tCardHolderRepository.GetCardHolder(CardHolderName);
         ICardRepository       tCardRespository      = new CardRepository(GiftEntity);
         int  ID       = Convert.ToInt32(IDstr);
         Guid CardGUID = WhichCard(DBCardHolder, ID);
         Card DBCard   = tCardRespository.GetCard(CardGUID);
         if (DBCard != null)
         {
             tCardHolderRepository.UnregisterCard(CardHolderName, CardGUID);
             tCardRespository.UnregisterCard(CardGUID);
         }
     }
 }
Esempio n. 4
0
        public int Pop(string id)
        {
            int res = -1;

            if (id != null)
            {
                try
                {
                    Card card = CardRepository.GetCard(id);
                    if (card != null && card.idx >= 0 && card.idx < Card.NumberOfCardsInDeck)
                    {
                        res = card.deck[card.idx];
                        card.idx++;
                        CardRepository.SaveCardAndUpdateLastUse(id, card);
                    }
                    else
                    {
                        if (card == null)
                        {
                            logger.Debug("Card is null");
                        }
                        else
                        {
                            logger.Debug($"Card index: {card.idx}");
                        }
                    }
                }
                catch (Exception e)
                {
                    logger.Error("Error at Poping card");
                    logger.Debug($"Error message {e.Message}");
                }
            }
            else
            {
                logger.Error("Invalid parameters.");
                logger.Debug($"Id: {id}");
            }
            return(res);
        }
Esempio n. 5
0
 public Card GetCard(string cardNumber)
 {
     return(cardRepository.GetCard(cardNumber));
 }
        List <CardHistory> IHistoryDAO.GetCardHistory(int CardID)
        {
            InitializeConnection();
            List <CardHistory> Histories = new List <CardHistory>();
            ICardRepository    CardData  = new CardRepository(GiftEntity);
            Card WhichCard = CardData.GetCard(CardID);

            if (WhichCard == null)
            {
                return(Histories);
            }
            var CardHistories = from c in GiftEntity.Histories
                                //join c2 in GiftEntity.Cards on c.Card2 equals c2.ID
                                where c.CardGUID == WhichCard.CardGUID &&
                                c.ErrorCode == "APP  " &&
                                (c.TransType == "ACTV" ||
                                 c.TransType == "SALE" ||
                                 c.TransType == "GTIP" ||
                                 c.TransType == "CRED" ||
                                 c.TransType == "BALN" ||
                                 c.TransType == "TRAN" ||
                                 c.TransType == "TPUP" ||
                                 c.TransType == "LYSL" ||
                                 c.TransType == "LYCR" ||
                                 c.TransType == "LYRM" ||
                                 c.TransType == "LYPR" ||
                                 c.TransType == "LEVT" ||
                                 c.TransType == "LVST" ||
                                 c.TransType == "CUCR" ||
                                 c.TransType == "CUDB" ||
                                 c.TransType == "DEPL")
                                //||
                                //c.Card2 == WhichCard.ID
                                select new
            {
                ID         = c.ID,
                CardGUID   = c.CardGUID,
                TransType  = c.TransType,
                When       = c.WhenHappened,
                Amount     = c.Amount,
                MerchWhere = c.WhichMerchantGUID,
                Clrk       = c.Clerk,
                Text       = c.TransactionText,
                //Card2 = c2.CardNumber,
                InvoiceNumber = c.InvoiceNumber
            };

            // need to restructure what we return to the calling program
            if (CardHistories == null)
            {
                return(Histories);
            }

            foreach (var Hist in CardHistories)
            {
                string CardNumber = (from c in GiftEntity.Cards
                                     where c.CardGUID == Hist.CardGUID
                                     orderby c.ID descending
                                     select c.CardNumLast4).FirstOrDefault();
                CardHistory Chist = new CardHistory();
                Chist.ID         = Hist.ID;
                Chist.CardNumber = CardNumber;
                Chist.MerchWhere = (from m in GiftEntity.Merchants
                                    where m.MerchantGUID == Hist.MerchWhere
                                    select m.MerchantName).FirstOrDefault();
                Chist.Clerk       = Hist.Clrk;
                Chist.When        = Hist.When;
                Chist.TransType   = Hist.TransType;
                Chist.Transaction = ConvertTransactionType(Hist.TransType);
                Chist.Amount      = Hist.Amount;
                Chist.Text        = Hist.Text;
                //Chist.Card2 = Hist.Card2;
                Chist.InvoiceNumber = Hist.InvoiceNumber;
                Histories.Add(Chist);
            }
            return(Histories);
        }
Esempio n. 7
0
        //
        // MembershipProvider.CreateCardHolder
        //

        public MembershipUser CreateCardHolder(
            CreateCardHolderModel WebData,
            out MembershipCreateStatus status)
        {
            MembershipUser user = null;

            // generate this user's username

            WebData.UserName = GenerateUserName(WebData.FirstName, WebData.LastName);

            // insure uniqueness by email address

            if (GetCardHolderByEmail(WebData.email) != "")
            {
                status = MembershipCreateStatus.DuplicateEmail;
                return(null);
            }

            // verify unique cardholder phone number

            ICardHolderRepository CardHolderRepositoryI = new CardHolderRepository();
            CardHolder            CH = CardHolderRepositoryI.GetCardHolderByPhoneNumber(WebData.CellPhoneNumber);

            if (CH != null)
            {
                status = MembershipCreateStatus.DuplicateProviderUserKey;
                return(null);
            }

            using (GiftEntities GiftEntity = new GiftEntities())
            {
                ICardHolderRepository CardHolderRepository = new CardHolderRepository(GiftEntity);
                ICardRepository       CardService          = new CardRepository(GiftEntity);


                // get the information for each card to be registered

                if (WebData.Card1 != null)
                {
                    Card tCard = CardService.GetCard(WebData.Card1);
                    if (tCard != null)
                    {
                        WebData.Card1GUID = tCard.CardGUID;
                    }
                }
                if (WebData.Card2 != null)
                {
                    Card tCard = CardService.GetCard(WebData.Card2);
                    if (tCard != null)
                    {
                        WebData.Card2GUID = tCard.CardGUID;
                    }
                }
                if (WebData.Card3 != null)
                {
                    Card tCard = CardService.GetCard(WebData.Card3);
                    if (tCard != null)
                    {
                        WebData.Card3GUID = tCard.CardGUID;
                    }
                }
                if (WebData.Card4 != null)
                {
                    Card tCard = CardService.GetCard(WebData.Card4);
                    if (tCard != null)
                    {
                        WebData.Card4GUID = tCard.CardGUID;
                    }
                }
                if (WebData.Card5 != null)
                {
                    Card tCard = CardService.GetCard(WebData.Card5);
                    if (tCard != null)
                    {
                        WebData.Card5GUID = tCard.CardGUID;
                    }
                }



                // create the cardholder record

                if (!CardHolderRepository.CreateCardHolder(WebData))
                {
                    status = MembershipCreateStatus.UserRejected;
                }
                else
                {
                    status = MembershipCreateStatus.Success;

                    user = _provider.CreateUser(WebData.UserName, WebData.Password, WebData.email, WebData.passwordQuestion, WebData.passwordAnswer, WebData.isApproved, WebData.providerUserKey, out status);
                    AddUserToCardHolderRole(WebData.UserName);

                    if (WebData.Card1 != null)
                    {
                        if (WebData.Card1.Length > 0)
                        {
                            CardService.RegisterCard(WebData.ID, WebData.CardHolderGUID, WebData.Card1);
                        }
                    }
                    if (WebData.Card2 != null)
                    {
                        if (WebData.Card2.Length > 0)
                        {
                            CardService.RegisterCard(WebData.ID, WebData.CardHolderGUID, WebData.Card2);
                        }
                    }
                    if (WebData.Card3 != null)
                    {
                        if (WebData.Card3.Length > 0)
                        {
                            CardService.RegisterCard(WebData.ID, WebData.CardHolderGUID, WebData.Card3);
                        }
                    }
                    if (WebData.Card4 != null)
                    {
                        if (WebData.Card4.Length > 0)
                        {
                            CardService.RegisterCard(WebData.ID, WebData.CardHolderGUID, WebData.Card4);
                        }
                    }
                    if (WebData.Card5 != null)
                    {
                        if (WebData.Card5.Length > 0)
                        {
                            CardService.RegisterCard(WebData.ID, WebData.CardHolderGUID, WebData.Card5);
                        }
                    }
                }
            }

            return(user);
        }