예제 #1
0
        public void Update(ClientCardInfo entity)
        {
            try
            {
                using (PSS2012DataContext context = this.DataContext)
                {
                    ClientCardInfo clientcardToUpdate = context.ClientCardInfos.Single(c => c.ClientCardGuid == entity.ClientCardGuid);

                    clientcardToUpdate.CardHolderNameOnCard = entity.CardHolderNameOnCard;
                    clientcardToUpdate.Cardtype = entity.Cardtype;
                    clientcardToUpdate.CardNumber = entity.CardNumber;
                    clientcardToUpdate.CvvNumber = entity.CvvNumber;
                    clientcardToUpdate.ExpMonth = entity.ExpMonth;
                    clientcardToUpdate.ExpYear = entity.ExpYear;

                    // Perform the update.
                    context.SubmitChanges();
                }
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw this.HandleSqlException(ex);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public ClientCardInfo Insert(ClientCardInfo entity)
        {
            //@@NEW - changed return type to entity type.
            try
            {
                ClientCardInfo daClientCardInfo = new ClientCardInfo();
                using (PSS2012DataContext context = this.DataContext)
                {
                    daClientCardInfo = (
                        from items in context.ClientCardInfos
                        where items.ClientGuid == entity.ClientGuid
                        select items).SingleOrDefault();

                    if (daClientCardInfo != null)
                        return daClientCardInfo;

                    entity.ClientCardGuid = Guid.NewGuid();
                    context.ClientCardInfos.InsertOnSubmit(entity);
                    context.SubmitChanges();
                }

                //@@NEW - returning full entity.
                return entity;
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw this.HandleSqlException(ex);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        public ClientCardInfo GetByClientGuid(System.Guid clientGuid)
        {
            if (Guid.Empty == clientGuid)
            { return new ClientCardInfo(); }

            try
            {
                ClientCardInfo daClientCardInfo = new ClientCardInfo();
                using (PSS2012DataContext context = this.DataContext)
                {
                    daClientCardInfo = (
                        from items in context.ClientCardInfos
                        where items.ClientGuid == clientGuid
                        select items).SingleOrDefault();
                }
                return daClientCardInfo;
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw this.HandleSqlException(ex);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #4
0
        private void SaveClientCardInfo(ClientCardInfoViewModel clientCardInfoVM, bool insert)
        {
            ClientCardInfoLogic logic = new ClientCardInfoLogic();
            ClientCardInfo clientCardInfo = new ClientCardInfo();

            clientCardInfo.CardType = clientCardInfoVM.CardType;
            clientCardInfo.CardHolderNameOnCard = Cryptographer.Encrypt(clientCardInfoVM.CardHolderNameOnCard, SetKey());
            clientCardInfo.CardNumber = Cryptographer.Encrypt(clientCardInfoVM.CardNumber, SetKey());
            clientCardInfo.ClientCardGuid= clientCardInfoVM.ClientCardGuid;
            clientCardInfo.ClientGuid = clientCardInfoVM.ClientGuid;
            clientCardInfo.CvvNumber = Cryptographer.Encrypt(clientCardInfoVM.CvvNumber, SetKey());
            clientCardInfo.ExpMonth = clientCardInfoVM.ExpMonth;
            clientCardInfo.ExpYear = clientCardInfoVM.ExpYear;
            if (insert)
                logic.InsertClientCardInfo(clientCardInfo);
            else
                logic.UpdateClientCardInfo(clientCardInfo);
        }
예제 #5
0
 private ClientCardInfoViewModel DecryptCCinfo(ClientCardInfo model)
 {
     ClientCardInfoViewModel clientCardInfoVM = new ClientCardInfoViewModel();
     clientCardInfoVM.CardType = model.CardType;
     clientCardInfoVM.CardHolderNameOnCard = Cryptographer.Decrypt(model.CardHolderNameOnCard,SetKey());
     clientCardInfoVM.CardNumber = Cryptographer.Decrypt(model.CardNumber,SetKey());
     clientCardInfoVM.ClientCardGuid = model.ClientCardGuid;
     clientCardInfoVM.ClientGuid = model.ClientGuid;
     clientCardInfoVM.CvvNumber = Cryptographer.Decrypt(model.CvvNumber, SetKey());
     clientCardInfoVM.ExpMonth = model.ExpMonth;
     clientCardInfoVM.ExpYear = model.ExpYear;
     return clientCardInfoVM;
 }