예제 #1
0
 bool IPriceDAO.UpdatePrice(Price ToUpdate)
 {
     InitializeConnection();
     GiftEntity.Prices.Attach(ToUpdate);
     GiftEntity.SaveChanges(); //SaveOptions.AcceptAllChangesAfterSave
     return(true);
 }
예제 #2
0
        void ICardHolderRepository.UpdateCardHolder(EditCardHolderModel WebData, String CardHolderName)
        {
            String EncryptedCardHolderName = GiftEncryption.Encrypt(CardHolderName);

            InitializeConnection();
            CardHolder DBCardHolder = (from c in GiftEntity.CardHolders
                                       where c.EncryptedCardHolderName == EncryptedCardHolderName
                                       select c).FirstOrDefault();

            if (DBCardHolder != null)
            {
                DBCardHolder.EncryptedFirstName = GiftEncryption.Encrypt(WebData.FirstName);
                DBCardHolder.LastName           = WebData.LastName;
                DBCardHolder.EncryptedLastName  = GiftEncryption.Encrypt(WebData.LastName);
                DBCardHolder.EncryptedAddress1  = GiftEncryption.Encrypt(WebData.Address1);
                DBCardHolder.EncryptedAddress2  = GiftEncryption.Encrypt(WebData.Address2);
                DBCardHolder.EncryptedCity      = GiftEncryption.Encrypt(WebData.City);
                DBCardHolder.State = WebData.State;
                DBCardHolder.EncryptedPostalCode = GiftEncryption.Encrypt(WebData.PostalCode);
                DBCardHolder.Country             = WebData.Country;
                String CleanPhoneNumber = extractPhoneNumber(WebData.CellPhoneNumber);
                DBCardHolder.EncryptedPhone = GiftEncryption.Encrypt(CleanPhoneNumber);
                DBCardHolder.EncryptedEmail = GiftEncryption.Encrypt(WebData.Email);

                GiftEntity.SaveChanges();
            }
        }
예제 #3
0
        bool ICardHolderRepository.CreateCardHolder(CreateCardHolderModel WebData)
        {
            CardHolder DBCardHolder = new CardHolder();

            DBCardHolder.CardHolderGUID          = Guid.NewGuid();
            DBCardHolder.EncryptedFirstName      = GiftEncryption.Encrypt(WebData.FirstName);
            DBCardHolder.LastName                = WebData.LastName;
            DBCardHolder.EncryptedLastName       = GiftEncryption.Encrypt(WebData.LastName);
            DBCardHolder.EncryptedCardHolderName = GiftEncryption.Encrypt(WebData.UserName);
            DBCardHolder.EncryptedEmail          = GiftEncryption.Encrypt(WebData.email.ToLower());
            DBCardHolder.EncryptedAddress1       = GiftEncryption.Encrypt(WebData.Address1);
            DBCardHolder.EncryptedAddress2       = GiftEncryption.Encrypt(WebData.Address2);
            DBCardHolder.EncryptedCity           = GiftEncryption.Encrypt(WebData.City);
            if (WebData.State != null)
            {
                DBCardHolder.State = WebData.State.ToUpper();
            }
            DBCardHolder.EncryptedPostalCode = GiftEncryption.Encrypt(WebData.PostalCode);
            String CleanPhoneNumber = extractPhoneNumber(WebData.CellPhoneNumber);

            DBCardHolder.EncryptedPhone = GiftEncryption.Encrypt(CleanPhoneNumber);
            DBCardHolder.Card1          = WebData.Card1GUID;
            DBCardHolder.Card2          = WebData.Card2GUID;
            DBCardHolder.Card3          = WebData.Card3GUID;
            DBCardHolder.Card4          = WebData.Card4GUID;
            DBCardHolder.Card5          = WebData.Card5GUID;

            GiftEntity.CardHolders.Add(DBCardHolder);
            GiftEntity.SaveChanges();
            WebData.ID             = DBCardHolder.ID;
            WebData.CardHolderGUID = (Guid)DBCardHolder.CardHolderGUID;
            return(true);
        }
 bool IMerchantDAO.CreateMerchant(Merchant ToAdd)
 {
     InitializeConnection();
     ToAdd.MerchantID = ToAdd.MerchantID.ToUpper();
     GiftEntity.Merchants.Add(ToAdd);
     GiftEntity.SaveChanges();
     return(true);
 }
예제 #5
0
 bool IPriceDAO.CreatePrice(Price NewPrice)
 {
     InitializeConnection();
     using (GiftEntity)
     {
         GiftEntity.Prices.Add(NewPrice);
         GiftEntity.SaveChanges();
     }
     return(true);
 }
        void ICardRepository.DeactivateCard(String CardToDeactivate)
        {
            String CleanCardNumber = extractCardNumber(CardToDeactivate);
            String EncryptedCard   = GiftEncryption.Encrypt(CleanCardNumber);
            Card   DBCard          = (from c in GiftEntity.Cards
                                      where c.CardNumber == EncryptedCard
                                      select c).FirstOrDefault();

            DBCard.Activated = "N";
            GiftEntity.SaveChanges();
        }
예제 #7
0
        void IPriceDAO.DeletePrice(int ID)
        {
            InitializeConnection();
            var Price = GiftEntity.Prices.FirstOrDefault(d => d.ID == ID);

            if (Price == null)
            {
                return;
            }
            GiftEntity.Prices.Remove(Price);
            GiftEntity.SaveChanges();
        }
        /// <summary>
        /// removes the link to the cardholder
        /// </summary>
        /// <param name="CardToUnregister"></param>
        void ICardRepository.UnregisterCard(Guid CardToUnregister)
        {
            InitializeConnection();
            Card DBCard = (from c in GiftEntity.Cards
                           where c.CardGUID == CardToUnregister
                           select c).FirstOrDefault();

            if (DBCard == null)
            {
                return;
            }
            DBCard.CardHolderGUID = null;
            GiftEntity.SaveChanges();
        }
        /// <summary>
        /// linkes the card to the cardholder
        /// </summary>
        /// <param name="CardHolderID"></param>
        /// <param name="CardToRegister"></param>
        void ICardRepository.RegisterCard(int CardHolderID, Guid?CardHolderGUID, String CardToRegister)
        {
            InitializeConnection();
            String CleanCardNumber = extractCardNumber(CardToRegister);
            String EncryptedCard   = GiftEncryption.Encrypt(CleanCardNumber);
            Card   DBCard          = (from c in GiftEntity.Cards
                                      where c.CardNumber == EncryptedCard
                                      select c).FirstOrDefault();

            if (DBCard != null)
            {
                DBCard.CardHolderGUID = CardHolderGUID;
                GiftEntity.SaveChanges();
            }
        }
예제 #10
0
        CardHolder ICardHolderRepository.RegisterThisCard(String CardHolderName, Guid NewCard)
        {
            int cardholderid = 0;

            InitializeConnection();
            String EncryptedCardHolderName = GiftEncryption.Encrypt(CardHolderName);

            CardHolder DBCardHolder = (from c in GiftEntity.CardHolders
                                       where c.EncryptedCardHolderName == EncryptedCardHolderName
                                       select c).FirstOrDefault();

            if (DBCardHolder == null)
            {
                throw new Exception("Card holder not found");
            }
            cardholderid = DBCardHolder.ID;
            if (DBCardHolder.Card1 == null)
            {
                DBCardHolder.Card1 = NewCard;
            }
            else
            if (DBCardHolder.Card2 == null)
            {
                DBCardHolder.Card2 = NewCard;
            }
            else
            if (DBCardHolder.Card3 == null)
            {
                DBCardHolder.Card3 = NewCard;
            }
            else
            if (DBCardHolder.Card4 == null)
            {
                DBCardHolder.Card4 = NewCard;
            }
            else
            if (DBCardHolder.Card5 == null)
            {
                DBCardHolder.Card5 = NewCard;
            }
            else
            {
                throw new Exception("Already five cards registered. Can not register more");
            }
            GiftEntity.SaveChanges();

            return(DBCardHolder);
        }
예제 #11
0
        bool ICardHolderRepository.UpdateEmail(String CardHolderName, String email, String comment, bool isapproved)
        {
            InitializeConnection();
            String     EncryptedUserName = GiftEncryption.Encrypt(CardHolderName);
            CardHolder DBCardHolder      = (from c in GiftEntity.CardHolders
                                            where c.EncryptedCardHolderName == EncryptedUserName
                                            select c).FirstOrDefault();

            if (DBCardHolder == null)
            {
                return(false);
            }
            DBCardHolder.EncryptedEmail = GiftEncryption.Encrypt(email);
            GiftEntity.SaveChanges();
            return(true);
        }
        public String AddThisCard(String EncryptedCard, String CardNumberLast4,
                                  String MerchantID, String ChainID, String GroupCode)
        {
            Card NewCard = GiftEntity.Cards.Create();

            NewCard.CardGUID     = Guid.NewGuid();
            NewCard.Activated    = "N";
            NewCard.Shipped      = "N";
            NewCard.CardNumber   = EncryptedCard;
            NewCard.CardNumLast4 = CardNumberLast4;
            NewCard.GiftBalance  = 0.00M;
            NewCard.MerchantGUID = null;
            GiftEntity.Cards.Add(NewCard);
            GiftEntity.SaveChanges();
            return("APP  ");
        }
예제 #13
0
        void ICardHolderRepository.UnregisterCard(String CardHolderName, Guid CardToUnregister)
        {
            InitializeConnection();
            String     EncryptedCardHolderName = GiftEncryption.Encrypt(CardHolderName);
            CardHolder DBCardHolder            = (from c in GiftEntity.CardHolders
                                                  where c.EncryptedCardHolderName == EncryptedCardHolderName
                                                  select c).FirstOrDefault();

            if (DBCardHolder != null)
            {
                if (DBCardHolder.Card1 == CardToUnregister)
                {
                    DBCardHolder.Card1 = DBCardHolder.Card2;
                    DBCardHolder.Card2 = DBCardHolder.Card3;
                    DBCardHolder.Card3 = DBCardHolder.Card4;
                    DBCardHolder.Card4 = DBCardHolder.Card5;
                    DBCardHolder.Card5 = null;
                }
                if (DBCardHolder.Card2 == CardToUnregister)
                {
                    DBCardHolder.Card2 = DBCardHolder.Card3;
                    DBCardHolder.Card3 = DBCardHolder.Card4;
                    DBCardHolder.Card4 = DBCardHolder.Card5;
                    DBCardHolder.Card5 = null;
                }
                if (DBCardHolder.Card3 == CardToUnregister)
                {
                    DBCardHolder.Card3 = DBCardHolder.Card4;
                    DBCardHolder.Card4 = DBCardHolder.Card5;
                    DBCardHolder.Card5 = null;
                }
                if (DBCardHolder.Card4 == CardToUnregister)
                {
                    DBCardHolder.Card4 = DBCardHolder.Card5;
                    DBCardHolder.Card5 = null;
                }
                if (DBCardHolder.Card5 == CardToUnregister)
                {
                    DBCardHolder.Card5 = null;
                }

                GiftEntity.SaveChanges();
            }
        }