public void CheckRefundedProfessionalPDT(SidejobEntities context, ProfessionalSuccessfulPDT e)
 {
     //Check if Record exist
     if ((from c in context.RefundProfessionalSuccessfulPDTs
          where PDTID == e.PDTID
          select c).FirstOrDefault() == null)
     {
         //Insert the new refund from the successful table
         var refund = new RefundProfessionalSuccessfulPDT
                          {
                              PDTID = e.PDTID,
                              GrossTotal = e.GrossTotal,
                              Invoice = e.Invoice,
                              PaymentStatus = e.PaymentStatus,
                              FirstName = e.FirstName,
                              LastName = e.LastName,
                              PaymentFee = e.PaymentFee,
                              BusinessEmail = e.BusinessEmail,
                              TxToken = e.TxToken,
                              ReceiverEmail = e.ReceiverEmail,
                              ItemName = e.ItemName,
                              CurrencyCode = e.CurrencyCode,
                              TransactionId = e.TransactionId,
                              Custom = e.Custom,
                              subscriberId = e.subscriberId,
                              ProID = e.ProID,
                              ProjectID = e.ProjectID
                          };
         context.AddToRefundProfessionalSuccessfulPDTs(refund);
         context.SaveChanges();
         PDTID = e.PDTID;
     }
 }
    public void CheckProfessionalArchivedPDT(int professionalId, SidejobEntities context)
    {
        //Check ArchivedSuccessful PDT
        var e1 = (from c in context.ArchivedProfessionalSuccessfulPDTs
                  where c.ProID == professionalId && c.ProjectID == ProjectID
                  select c).FirstOrDefault();
        if (e1 != null)
        {
            var transaction = e1.TransactionId;
            //Insert the new refund from archieved table

            //Check if Transaction exist in Refund
            var exist = (from c in context.RefundProfessionalSuccessfulPDTs
                         where c.TransactionId == transaction
                         select c).FirstOrDefault();
            if (exist == null)
            {
                //Check if Transaction exist in ArchivedRefund
                var existarchived = (from c in context.ArchivedRefundProfessionalSuccessfulPDTs
                                     where c.TransactionId == transaction
                                     select c).FirstOrDefault();

                if (existarchived == null)
                {
                    //Check if Record exist
                    if ((from c in context.RefundProfessionalSuccessfulPDTs
                         where PDTID == e1.PDTID
                         select c).FirstOrDefault() == null)
                    {
                        //Insert the new record
                        var archivedrefund = new RefundProfessionalSuccessfulPDT
                                                 {
                                                     PDTID = e1.PDTID,
                                                     GrossTotal = e1.GrossTotal,
                                                     Invoice = e1.Invoice,
                                                     PaymentStatus = e1.PaymentStatus,
                                                     FirstName = e1.FirstName,
                                                     LastName = e1.LastName,
                                                     PaymentFee = e1.PaymentFee,
                                                     BusinessEmail = e1.BusinessEmail,
                                                     TxToken = e1.TxToken,
                                                     ReceiverEmail = e1.ReceiverEmail,
                                                     ItemName = e1.ItemName,
                                                     CurrencyCode = e1.CurrencyCode,
                                                     TransactionId = e1.TransactionId,
                                                     Custom = e1.Custom,
                                                     subscriberId = e1.subscriberId,
                                                     ProID = e1.ProID,
                                                     ProjectID = e1.ProjectID
                                                 };
                        context.AddToRefundProfessionalSuccessfulPDTs(archivedrefund);
                        context.SaveChanges();
                        PDTID = e1.PDTID;
                    }
                }
            }
        }
    }