public void AutomatedMessageProcessStart()
    {
        using (var context = new SidejobEntities())
        {
            var message = (from c in context.AutomatedMessages
                           select c).ToList();

            if (message.Count == 0) return;
            foreach (var m in message)
            {
                try
                {
                    SendEmail(m.EmailAddress,
                              "http://www.my-side-job.com/Schedule/MySideJob/EmailTemplates/AutomatedMessage.aspx",
                              m.Title, m.MessageID.ToString(CultureInfo.InvariantCulture));
                   // context.DeleteObject(m);
                    context.SaveChanges();
                }
                catch (Exception)
                {
                    CatchMessage(context, m);
                }
            }
        }
    }
 public void EmailAutomation()
 {
     using (var context = new SidejobEntities())
     {
         var message = (from c in context.AutomatedMessages
                        select c).ToList();
         if (message.Count != 0)
         {
             foreach (var e in message)
             {
                 try
                 {
                     SendEmail(e.EmailAddress, e.Title, e.MessageID.ToString(CultureInfo.InvariantCulture), Server.MapPath("~/EmailTemplates/AutomatedMessage.aspx"), Message.Automated);
                 }
                 catch (Exception emailexception)
                 {
                     var emailProblem = new AutomationEmailProblem
                                            {
                                                MessageID = e.MessageID,
                                                EmailAddress = e.EmailAddress,
                                                Title = e.Title,
                                                Message = e.Message
                                            };
                     context.AddToAutomationEmailProblems(emailProblem);
                 }
             }
         }
         context.DeleteObject(message);
         context.SaveChanges();
     }
 }
 //private void GetValue(SidejobEntities context)
 //{
 //    var projectsecondchance = (from c in context.ProjectSecondChances
 //                               where c.ProjectID == ProjectID
 //                               select c).ToList();
 //    if (projectsecondchance.Count != 0)
 //    {
 //        foreach (var psc in projectsecondchance)
 //        {
 //            context.DeleteObject(psc);
 //            context.SaveChanges();
 //        }
 //    }
 //}
 private void GetValue(SidejobEntities context, ICollection somelist)
 {
     if (somelist.Count <= 0) return;
     foreach (var item in somelist)
     {
         context.DeleteObject(item);
         context.SaveChanges();
     }
 }
 public void CatchMessage(SidejobEntities context, AutomatedMessage m)
 {
     var messageProblem = new AutomationEmailProblem
     {
         MessageID = m.MessageID,
         EmailAddress = m.EmailAddress,
         Title = m.Title,
         Message = m.Message
     };
     context.AddToAutomationEmailProblems(messageProblem);
     context.SaveChanges();
 }
    public void DeleteFromResponseDelay(SidejobEntities context)
    {
        var rd = (from c in context.ResponseDelays
                  where c.ProjectID == ProjectID
                  select c).FirstOrDefault();

        if ( rd != null)
        {
            context.DeleteObject(rd);
            context.SaveChanges();
        }
    }
 public void AddNewBidderWin(SidejobEntities context, int projectId)
 {
     var newBid = GetCurrentNewBid(projectId, NewProID);
     var newwin = new ProfessionalWinBid
                      {
                          BidID = newBid.BidID,
                          ProID = NewProID,
                          NumberofBids = GetNumberofBids(context)
                      };
     context.AddToProfessionalWinBids(newwin);
     context.SaveChanges();
 }
 public static void BidderResponseDelayUpdate(int projectid)
 {
     using (var context = new SidejobEntities())
     {
         var rd = (from c in context.ResponseDelays
                   where c.ProjectID == projectid
                   select c).FirstOrDefault();
         if (rd != null)
         {
             rd.Status = 4;
             context.SaveChanges();
         }
     }
 }
 public void CatchMessage(string id)
 {
     using (var context = new SidejobEntities())
     {
         var messageProblem = new AutomationEmailProblem
                                  {
                                      MessageID = GetMessageID(context),
                                      EmailAddress = "From Sending Message",
                                      Title = "Go Find It",
                                      Message ="Check AutomatedMessageTable"
                                  };
         context.AddToAutomationEmailProblems(messageProblem);
         context.SaveChanges();
     }
 }
    public void DeleteAllBids(SidejobEntities context, int projectId, int bidderid)
    {
        var bids = (from c in context.Bids
                    where c.ProjectID == projectId
                    orderby c.AmountOffered descending
                    select c).ToList();
        if (bids.Count != 0)
        {
            foreach (var b in bids)
            {
                context.DeleteObject(b);
            }
        }

        context.SaveChanges();
    }
    protected void AutomatedEmailProblemGridViewSelectedIndexChanged(object sender, EventArgs e)
    {
        //Issue is fixed, then delete it
        if (AutomatedEmailProblemGridView.SelectedDataKey == null) return;
        var selected = (int)AutomatedEmailProblemGridView.SelectedDataKey.Value;

        using (var context = new SidejobEntities())
        {
            var current = (from c in context.AutomationEmailProblems
                           where c.MessageID == selected
                           select c).FirstOrDefault();
            if (current != null)
            {
                context.DeleteObject(current);
                context.SaveChanges();
            }

        }
    }
        protected void EmailSentExceptionGridViewSelectedIndexChanged(object sender, EventArgs e)
        {
            //Issue is fixed, then delete it
            if (EmailSentExceptionGridView.SelectedDataKey == null) return;
            var selected = (int)EmailSentExceptionGridView.SelectedDataKey.Value;

            using (var context = new SidejobEntities())
            {
                var current = (from c in context.EmailSentExceptions
                               where c.ID == selected
                               select c).FirstOrDefault();
                if (current != null)
                {
                    context.DeleteObject(current);
                    context.SaveChanges();
                    Response.Redirect(Context.Request.Url.ToString());
                }

            }
        }
    public void AddNewBidderWin(SidejobEntities context, int projectId)
    {
        var newBid = GetCurrentNewBid(projectId, NewProID);
        if (newBid == null) return;
        try
        {
            var newwin = new ProfessionalWinBid
                         {
                             BidID = newBid.BidID,
                             ProID = NewProID,
                             NumberofBids = GetNumberofBids(context)
                         };
            context.AddToProfessionalWinBids(newwin);
            context.SaveChanges();

        }
        catch (Exception e)
        {

            var i = e;
        }
    }
    public static void AddToBidderCompletedProjectSucessPayment(int projectid, int payerid, string payerole)
    {
        var context = new SidejobEntities();
        var biddercompletedprojectsucesspayment = new CompletedProjectSucessPayment
                                                      {
                                                          PayerID = payerid,
                                                          PayerProjectRole = "BIDDER",
                                                          PayerRole = payerole,
                                                          ProjectID = projectid
                                                      };
        context.AddToCompletedProjectSucessPayment(biddercompletedprojectsucesspayment);
        context.SaveChanges();

        //check to see if the poster has already made the payment:
        var posterpayment = (from c in context.CompletedProjectSucessPayment
                             where c.ProjectID == projectid && c.PayerProjectRole == "POSTER"
                             select c).FirstOrDefault();
        if (posterpayment != null)
        {
            //poster
            PosterSuccessPayment(projectid, 4, posterpayment.PayerRole, posterpayment.PayerID);
        }
    }
Beispiel #14
0
 protected void CustomerGridViewSelectedIndexChanged(object sender, EventArgs e)
 {
     if (CustomerGridView.SelectedDataKey == null) return;
     var selected = (int) CustomerGridView.SelectedDataKey.Value;
     //Archive the refund
     //After you did it manually through Paypal
     using (var context = new SidejobEntities())
     {
         var current = (from c in context.RefundCustomerSuccessfulPDTs
                        where c.PDTID == selected
                        select c).FirstOrDefault();
         if (current != null)
         {
             var archive = new ArchivedRefundCustomerSuccessfulPDT
                               {
                                   PDTID = current.PDTID,
                                   GrossTotal = current.GrossTotal,
                                   Invoice = current.Invoice,
                                   PaymentStatus = current.PaymentStatus,
                                   FirstName = current.FirstName,
                                   LastName = current.LastName,
                                   PaymentFee = current.PaymentFee,
                                   BusinessEmail = current.BusinessEmail,
                                   TxToken = current.TxToken,
                                   ReceiverEmail = current.ReceiverEmail,
                                   ItemName = current.ItemName,
                                   TransactionId = current.TransactionId,
                                   Custom = current.Custom,
                                   subscriberId = current.subscriberId,
                                   CustomerID = current.CustomerID,
                                   ProjectID = current.ProjectID
                               };
             context.AddToArchivedRefundCustomerSuccessfulPDTs(archive);
             context.SaveChanges();
         }
     }
 }
 protected void ArchiveRefund(int pdtid)
 {
     using (var context = new SidejobEntities())
     {
         var currentrefund = (from c in context.RefundCustomerSuccessfulPDTs
                              where c.PDTID == pdtid
                              select c).FirstOrDefault();
         if(currentrefund != null)
         {
             var archivedrefund = new ArchivedRefundCustomerSuccessfulPDT
                                      {
                                          PDTID = currentrefund.PDTID,
                                          GrossTotal = currentrefund.GrossTotal,
                                          Invoice = currentrefund.Invoice,
                                          PaymentStatus = currentrefund.PaymentStatus,
                                          FirstName = currentrefund.FirstName,
                                          LastName = currentrefund.LastName,
                                          PaymentFee = currentrefund.PaymentFee,
                                          BusinessEmail = currentrefund.BusinessEmail,
                                          TxToken = currentrefund.TxToken,
                                          ReceiverEmail = currentrefund.ReceiverEmail,
                                          ItemName = currentrefund.ItemName,
                                          CurrencyCode = currentrefund.CurrencyCode,
                                          TransactionId = currentrefund.TransactionId,
                                          Custom = currentrefund.Custom,
                                          subscriberId = currentrefund.subscriberId,
                                          CustomerID = currentrefund.CustomerID,
                                          ProjectID = currentrefund.ProjectID
                                      };
             context.AddToArchivedRefundCustomerSuccessfulPDTs(archivedrefund);
             context.DeleteObject(currentrefund);
             context.SaveChanges();
             Response.Redirect(Context.Request.Url.ToString());
         }
     }
 }
    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;
                    }
                }
            }
        }
    }
    public void BlockPoster(SidejobEntities context)
    {
        if (PosterRole == "CUS")
        {
            //Add to BlockedCustomer
            var cg = (from c in context.CustomerGenerals
                      where c.CustomerID == PosterID
                      select c).FirstOrDefault();

            if (cg != null)
            {
                if (((from c in context.LockedCustomers
                      where c.CustomerID == cg.CustomerID
                      select c).FirstOrDefault()) == null)
                {
                    var lockedcustomer = new LockedCustomer
                                             {
                                                 FirstName = cg.FirstName,
                                                 LastName = cg.LastName,
                                                 Country = cg.CountryName,
                                                 Region = cg.RegionName,
                                                 Age = cg.Age,
                                                 Gender = cg.Gender,
                                                 EmailAddress = cg.EmailAddress,
                                                 Reason = "NOT Paying Project" + ProjectID,
                                                 Date = DateTime.Now.Date,
                                                 IP = 0,
                                                 CustomerID = cg.CustomerID,
                                                 ProjectID = ProjectID
                                             };
                    context.AddToLockedCustomers(lockedcustomer);
                }
            }
            context.SaveChanges();
        }
        if (PosterRole == "PRO")
        {
            //Add to BlockedProfessional
            var pg = (from c in context.ProfessionalGenerals
                      where c.ProID == PosterID
                      select c).FirstOrDefault();
            if (pg != null)
            {
                if (((from c in context.LockedProfessionals
                      where c.ProID == pg.ProID
                      select c).FirstOrDefault()) == null)
                {
                    var lockedprofessional = new LockedProfessional
                                                 {
                                                     FirstName = pg.FirstName,
                                                     LastName = pg.LastName,
                                                     Country = pg.CountryName,
                                                     Region = pg.RegionName,
                                                     Age = pg.Age,
                                                     Gender = pg.Gender,
                                                     EmailAddress = pg.EmailAddress,
                                                     Reason = "NOT Paying Project" + ProjectID,
                                                     Date = DateTime.Now.Date,
                                                     IP = 0,
                                                     ProID = pg.ProID,
                                                     ProjectID = ProjectID
                                                 };

                    context.AddToLockedProfessionals(lockedprofessional);
                }
            }

            context.SaveChanges();
        }
    }
    protected void ChecKTime()
    {
        using (var context = new SidejobEntities())
        {
            //var responseDelay = DateTime.UtcNow.Date.AddHours(72);
            var t = (from c in context.ResponseDelays
                     select c).ToList();
            foreach (SidejobModel.ResponseDelay t1 in t)
            {
                if (t1.DateFinished.Date.AddHours(72) <= DateTime.UtcNow.Date)
                {
                    GetBidderPosterProjectProperties(t1);
                    var status = t1.Status;
                    //Case 0 waiting for Case 2
                    /////////////Project closed and no action from the bidder//////////////
                    BidderDelay(status, context, t1);
                    /////////////Project closed and no action from the bidder//////////////

                    //Case 2 waiting for Case 4
                    ////////////////////////////////Poster no payment////////////////////////////
                    PosterDelay(context, status, t1);
                    ////////////////////////////////Poster no payment////////////////////////////

                    ///////////////////////////////////FOR PDT/IPN  MORE CHANGE SEE THE DOCUMENT 72HOURS///////////////////////////////////
                    context.SaveChanges();
                    ///////////////////////////////////FOR PDT/IPN  MORE CHANGE SEE THE DOCUMENT 72HOURS///////////////////////////////////
                }
            }

        }
    }
 public void RefundProfessional(int professionalId)
 {
     //Check Successful PDT and Check ArchivedSuccessful PDT
     using (var context = new SidejobEntities())
     {
         //Check Successful PDT
         var e = (from c in context.ProfessionalSuccessfulPDTs
                  where c.ProID == professionalId && c.ProjectID == ProjectID
                  select c).FirstOrDefault();
         if (e == null)
         {
             CheckProfessionalArchivedPDT(professionalId, context);
         }
         else
         {
             CheckRefundedProfessionalPDT(context, e);
             context.DeleteObject(e);
             context.SaveChanges();
         }
     }
 }
 public void RefundCustomer(int customerId)
 {
     //Check Successful PDT and Check ArchivedSuccessful PDT
     using (var context = new SidejobEntities())
     {
         //Check Successful PDT
         var e = (from c in context.CustomerSuccessfulPDTs
                  where c.CustomerID == customerId && c.ProjectID == ProjectID
                  select c).FirstOrDefault();
         if (e == null)
         {
             CheckCustomerArchivedPDT(customerId, context);
         }
         else
         {
             CheckRefundedCustomerPDT(customerId, e, context);
             context.DeleteObject(e);
             context.SaveChanges();
         }
     }
 }
        protected void NewAggrement(int projectid, int customerid)
        {
            using (var context = new SidejobEntities())
            {

                //the other party aggree had already Aggreed
                //add the new record to ProjectSecondChance
                var bidderparty = (from c in context.ProjectSecondChances
                                   where c.ProjectID == projectid && c.AgreerID == ProfessionalID
                                   select c).FirstOrDefault();

                if (bidderparty != null) return;
                var newparty = new ProjectSecondChance
                                   {
                                       ProjectID = projectid,
                                       AgreerID = ProfessionalID,
                                       AgreerRole = "PRO",
                                       DateTime = DateTime.Now.Date,
                                       AgreerProjectRole = GetProjectRole(projectid)
                                   };
                context.AddToProjectSecondChances(newparty);
                context.SaveChanges();
            }
        }
Beispiel #22
0
    public void GetFinishedPorjects()
    {
        //Check to see which projects time is finished and projects are open
        using (var context = new SidejobEntities())
        {
            var projects = (from pr in context.ProjectRequirements
                            join p in context.Projects on
                                pr.ProjectID equals p.ProjectID
                            where (pr.EndDate >= DateTime.UtcNow) && (p.StatusInt == 0)
                            select p).ToList();

            foreach (var p in projects)
            {
                //UpdateProject to Closed
                p.StatusInt = 3;
                context.SaveChanges();

                //Add To ClosedProject
                AddToClosedProject((int)p.ProjectID);

                //Check if you need to change back from var to int
                var projectID = (int)p.ProjectID;

                //Update Winner
                var bidder = (from b in context.Bids
                              where b.ProjectID == projectID
                              select b).FirstOrDefault();
                if (BidderRole == "CUS")
                {
                    CustomerWin(bidder);
                }
                if (BidderRole == "PRO")
                {
                    ProWin(bidder);
                }
            }
        }
    }
 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;
     }
 }
        protected void NewAggrement(int projectid, int professionalId)
        {
            using (var context = new SidejobEntities())
            {
                //The other party aggree can only be Bidder
                //add the new record to ProjectSecondChance
                var posterparty = (from c in context.ProjectSecondChances
                                   where c.ProjectID == projectid && c.AgreerID == professionalId
                                   select c).FirstOrDefault();

                if (posterparty != null) return;
                var newparty = new ProjectSecondChance
                {
                    ProjectID = projectid,
                    AgreerID = professionalId,
                    AgreerRole = "PRO",
                    DateTime = DateTime.Now.Date,
                    AgreerProjectRole = GetProjectRole(projectid, professionalId)
                };
                context.AddToProjectSecondChances(newparty);
                context.SaveChanges();
                GetNextBidder(2, context, projectid);
            }
        }
    public void PosterDelay(SidejobEntities context, int status, SidejobModel.ResponseDelay t1)
    {
        if (status == 4)
        {
            var reminderLevel = t1.ReminderLevel;
            if (reminderLevel == 0)
            {
                // Email Poster. Email Bidder
                // Warn Poster with reminder  1
                //Update Time Delay to Reminder level  1

                EmailPoster(t1, Message.Warning);
                EmailBidder(t1, Message.Notification);
                t1.ReminderLevel = 1;

            }
            if (reminderLevel == 1)
            {
                // Email Poster. Email Bidder
                // Warn Poster with reminder 2
                //Update Time Delay to Reminder level 2

                EmailPoster(t1, Message.Warning);
                EmailBidder(t1, Message.Notification);
                t1.ReminderLevel = 2;
            }

            if (reminderLevel == 2)
            {
                // Email Poster. Email Bidder
                // Warn Poster with reminder 3
                //Update Time Delay to Reminder level 3

                EmailPoster(t1, Message.Warning);
                EmailBidder(t1, Message.Notification);
                t1.ReminderLevel = 3;
            }
            if (reminderLevel == 3)
            {
                ////////////////////////////////Poster no payment////////////////////////////

                //  Add The Poster to blocked poster
                BlockPoster(context);

                // Email Bidder & Email Poster
                //Throught Button in CustomerRefund or ProfessionalRefund
                //   EmailBidder(t1, Message.Refund);

                EmailPoster(t1, Message.Blocked);

                //Refund Bidder
                RefundBidder();
                //Through PayPalAPI inthe future
                ////////////////////////////////////////
                //Delete from ClosedProject
                var closedproject = (from c in context.ClosedProjects
                                     where c.ProjectID == ProjectID
                                     select c).FirstOrDefault();
                if (closedproject != null)
                {
                    context.DeleteObject(closedproject);
                }
                context.SaveChanges();

                //Insert into archived
                var currentproject = (from c in context.Projects
                                      where c.ProjectID == ProjectID
                                      select c).FirstOrDefault();
                var currentprojectphoto = (from c in context.ProjectPhotoes
                                           where c.ProjectID == ProjectID
                                           select c).ToList();
                var currentprojectpicture = (from c in context.ProjectPictures
                                             where c.ProjectID == ProjectID
                                             select c).FirstOrDefault();
                var currentprojectrequirement = (from c in context.ProjectRequirements
                                                 where c.ProjectID == ProjectID
                                                 select c).FirstOrDefault();
                if (currentproject != null)
                {
                    if (currentprojectrequirement != null)
                    {
                        if ((from c in context.ArchievedCancelledProjects
                             where c.ProjectID == ProjectID
                             select c).FirstOrDefault() == null)
                        {
                            var acp = new ArchievedCancelledProject
                                          {
                                              ProjectID = (int)currentproject.ProjectID,
                                              DateFinished = DateTime.Now.Date,
                                              PosterID = PosterID,
                                              PosterRole = PosterRole,
                                              BidderID = BidderID,
                                              BidderRole = BidderRole,
                                              HighestBid = currentproject.HighestBid,
                                              Currency = currentprojectrequirement.CurrencyID,
                                              Status = currentproject.StatusInt
                                          };
                            context.AddToArchievedCancelledProjects(acp);
                        }
                    }
                }

                //for each record
                foreach (var cp in currentprojectphoto)
                {
                    if ((from c in context.ArchievedCancelledProjectPhotoes
                         where c.PhotoID == cp.PhotoID
                         select c).FirstOrDefault() == null)
                    {
                        var ac = new ArchievedCancelledProjectPhoto
                                     {
                                         PhotoID = cp.PhotoID,
                                         ProjectID = cp.ProjectID,
                                         PhotoPath = cp.PhotoPath,
                                         Caption = cp.Caption,
                                         AlbumID = cp.AlbumID,
                                         PhotoRank = cp.PhotoRank
                                     };
                        context.AddToArchievedCancelledProjectPhotoes(ac);
                    }
                }

                if (currentprojectpicture != null)
                {
                    if ((from c in context.ArchievedCancelledProjectPictures
                         where c.AlbumID == currentprojectpicture.AlbumID
                         select c).FirstOrDefault() == null)
                    {
                        var acpi = new ArchievedCancelledProjectPicture
                                       {
                                           AlbumID = currentprojectpicture.AlbumID,
                                           AlbumCaption = currentprojectpicture.AlbumCaption,
                                           Numberofimages = currentprojectpicture.Numberofimages,
                                           ProjectID = currentprojectpicture.ProjectID
                                       };
                        context.AddToArchievedCancelledProjectPictures(acpi);
                    }
                }

                if (currentprojectrequirement != null)
                {
                    if ((from c in context.ArchievedCancelledProjectRequirements
                         where c.ProjectID == currentprojectpicture.AlbumID
                         select c).FirstOrDefault() == null)
                    {
                        var acpr = new ArchievedCancelledProjectRequirement
                                       {
                                           ProjectID = currentprojectrequirement.ProjectID,
                                           LCID = currentprojectrequirement.LCID,
                                           CategoryID = currentprojectrequirement.CategoryID,
                                           CategoryName = currentprojectrequirement.CategoryName,
                                           JobID = currentprojectrequirement.JobID,
                                           JobTitle = currentprojectrequirement.JobTitle,
                                           ExperienceID = currentprojectrequirement.ExperienceID,
                                           CrewNumberID = currentprojectrequirement.CrewNumberID,
                                           LicensedID = currentprojectrequirement.LicensedID,
                                           InsuredID = currentprojectrequirement.InsuredID,
                                           RelocationID = currentprojectrequirement.RelocationID,
                                           ProjectTitle = currentprojectrequirement.ProjectTitle,
                                           StartDate = currentprojectrequirement.StartDate,
                                           EndDate = currentprojectrequirement.EndDate,
                                           AmountOffered = currentprojectrequirement.AmountOffered,
                                           CurrencyID = currentprojectrequirement.CurrencyID,
                                           Description = currentprojectrequirement.Description,
                                           SpecialNotes = currentprojectrequirement.SpecialNotes,
                                           Address = currentprojectrequirement.Address,
                                           CountryID = currentprojectrequirement.CountryID,
                                           CountryName = currentprojectrequirement.CountryName,
                                           RegionID = currentprojectrequirement.RegionID,
                                           RegionName = currentprojectrequirement.RegionName,
                                           CityID = currentprojectrequirement.CityID,
                                           CityName = currentprojectrequirement.CityName,
                                           Zipcode = currentprojectrequirement.Zipcode,
                                           DatePosted = currentprojectrequirement.DatePosted,
                                           TimeLeft = currentprojectrequirement.TimeLeft
                                       };

                        context.AddToArchievedCancelledProjectRequirements(acpr);
                    }
                }
                context.SaveChanges();

                //delete from current project
                if (currentprojectrequirement != null) context.DeleteObject(currentproject);
                if (currentprojectphoto.Count != 0)
                {
                    foreach (var cp in currentprojectphoto)
                    {
                        context.DeleteObject(cp);
                    }

                }
                if (currentprojectpicture != null) context.DeleteObject(currentprojectpicture);
                if (currentprojectrequirement != null) context.DeleteObject(currentprojectrequirement);
                t1.ReminderLevel = 4;
                context.SaveChanges();
                ///////////////////////////////Poster no payment////////////////////////////
            }
        }
    }
Beispiel #26
0
 public void CustomerWin(Bid bidder)
 {
     var context = new SidejobEntities();
     var customerwinbid = new CustomerWinBid
     {
         BidID = bidder.BidID,
         CustomerID = bidder.BidderID,
         NumberofBids = GetCustomerNumberofBids(bidder.BidderID)
     };
     context.AddToCustomerWinBids(customerwinbid);
     context.DeleteObject(bidder);
     context.SaveChanges();
 }
        private static void ExtendProject(int projectid)
        {
            using (var context = new SidejobEntities())
            {

                //Extend Project ( Make statusInt = 0 and ouput message)

                // Delete the previous bidder in Project
                var newBidProcess = new NewProjectBidProcess(PreviousBidderID, ProjectID);
                newBidProcess.DeleteAllBids(context, ProjectID, PreviousBidderID);

                //Delete From ClosedProject
                var closedproject = (from c in context.ClosedProjects
                                     where c.ProjectID == projectid
                                     select c).FirstOrDefault();
                if (closedproject != null)
                {
                    context.DeleteObject(closedproject);
                }

                //Delete From ResponseDelay
                var rd = (from c in context.ResponseDelays
                          where c.ProjectID == projectid
                          select c).FirstOrDefault();
                if (rd != null)
                {
                    context.DeleteObject(rd);
                    context.SaveChanges();
                }

                //Update Project Requirement End Date to Today + 7 days
                var projectrequirement = (from c in context.ProjectRequirements
                                          where c.ProjectID == projectid
                                          select c).FirstOrDefault();
                if (projectrequirement != null)
                {
                    projectrequirement.DatePosted = DateTime.UtcNow.Date.AddDays(7);
                    context.SaveChanges();
                }

                //Clear Project Winning Bid
                var project = (from c in context.Projects
                               where c.ProjectID == projectid
                               select c).FirstOrDefault();
                if (project == null) return;
                project.StatusInt = 0;
                project.Status = Resources.Resource.OPEN;
                project.HighestBid = null;
                project.HighestBidderID = null;
                project.HighestBidUsername = null;
                project.NumberofBids = 0;
                context.SaveChanges();
            }
        }
Beispiel #28
0
    public void BidderPayFees(ClosedProject cp)
    {
        //        ----------------------------Bidder Pay Fees-------------------------------------

        var context = new SidejobEntities();
        cp.Status = 4;
        context.SaveChanges();

        Postermessage = Resources.Resource.PosterBidCongratulation;

        if (cp.CurrencyID != null)
            Postermessage += "<b>" + cp.HighestBid + ScheduleMySide.Helpers.Utility.GetCurrencyCode((int)cp.CurrencyID) + "</b>";
        Postermessage += Resources.Resource.PosterRequestPayment;

        Biddermessage = Resources.Resource.BidderPaymentConfirmation;

        Phasetitle = Resources.Resource.BidConfirmationPhase;

        //---------------------------------Action 2:--------------------------------------
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                // Used parts from https://www.paypaltech.com/PDTGen/
                // Visit above URL to auto-generate PDT script

                authToken = WebConfigurationManager.AppSettings["PDTToken"];

                //read in txn token from querystring
                txToken = Request.QueryString.Get("tx");

                query = string.Format("cmd=_notify-synch&tx={0}&at={1}", txToken, authToken);

                // Create the request back
                string url = WebConfigurationManager.AppSettings["PayPalSubmitUrl"];
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);

                // Set values for the request back
                req.Method = "POST";
                req.ContentType = "application/x-www-form-urlencoded";
                req.ContentLength = query.Length;

                // Write the request back IPN strings
                StreamWriter stOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
                stOut.Write(query);
                stOut.Close();

                // Do the request to PayPal and get the response
                StreamReader stIn = new StreamReader(req.GetResponse().GetResponseStream());
                strResponse = stIn.ReadToEnd();
                stIn.Close();

                //string strResponse = "SUCCESS mc_gross=145.35 protection_eligibility=Ineligible address_status=confirmed payer_id=WJ3SRWX9PXP94 tax=0.00 address_street=1+Main+St payment_date=07%3A13%3A35+Sep+06%2C+2012+PDT payment_status=Pending terminal_id= charset=windows-1252 address_zip=95131 first_name=sdgsd receipt_reference_number= mc_fee=4.52 address_country_code=US address_name=sdgsd+sdgs custom=80%2C9b5dc3f5-54d2-413b-9803-1fbabe6770ac payer_status=verified business=sellpr_1346179874_biz%40yahoo.com address_country=United+States address_city=San+Jose quantity=1 payer_email=adver_1345188328_per%40yahoo.com txn_id=059835996R2655052 payment_type=instant last_name=sdgs address_state=CA receiver_email=sellpr_1346179874_biz%40yahoo.com store_id= payment_fee=4.52 receiver_id=EVBLGJGBR8RL8 pending_reason=paymentreview pos_transaction_type= txn_type=web_accept item_name=ewtwet num_offers=0 mc_currency=USD item_number=1 residence_country=US handling_amount=0.00 transaction_subject=80%2C9b5dc3f5-54d2-413b-9803-1fbabe6770ac payment_gross=145.35 shipping=0.00 ";
                // sanity check

                //Response.Write(strResponse);

                string CustomerID = GetCustomerID();

                PDTHolder pdt = PDTHolder.Parse(strResponse);

                // If response was SUCCESS, parse response string and output details
                //The payment is succesful
                if (strResponse.StartsWith("SUCCESS"))
                {
                    using (var context = new SidejobEntities())
                    {
                        try
                        {
                            var Custom = pdt.Custom.Split(',');
                            //var custom = GetProjectID() + "," + GetCustomerID() + "," + GetPaymentID();
                            int ProjectId = int.Parse(Custom[0]);
                            int CustomerId = int.Parse(Custom[1]);
                            int PaymentId = int.Parse(Custom[2]);

                            var result = from c in context.ArchivedCustomerSuccessfulPDTs
                                          where c.CustomerID == CustomerId && c.ProjectID == ProjectId && c.TransactionId == pdt.TransactionId
                                          select c;
                              var resultQuery = result.FirstOrDefault();
                              if (resultQuery == null)
                              {
                                  HiddenLabel.Text = string.Format("Thank you {0} {1} [{2}] for your payment of {3} {4}!",
                                                                pdt.PayerFirstName, pdt.PayerLastName, pdt.PayerEmail, pdt.GrossTotal, pdt.Currency);

                                  //Insert into Successful PDT
                                  var CustomerSuccessfulPDT = new CustomerSuccessfulPDT
                                  {
                                      PDTID = GetNextSuccessfulPDTID(),
                                      GrossTotal = pdt.GrossTotal,
                                      Invoice = pdt.InvoiceNumber,
                                      PaymentStatus = pdt.PaymentStatus,
                                      FirstName = pdt.PayerFirstName,
                                      LastName = pdt.PayerLastName,
                                      PaymentFee = pdt.PaymentFee,
                                      BusinessEmail = pdt.BusinessEmail,
                                      TxToken = Request.QueryString.Get("tx"),
                                      ReceiverEmail = pdt.ReceiverEmail,
                                      ItemName = pdt.ItemName,
                                      CurrencyCode = pdt.Currency,
                                      TransactionId = pdt.TransactionId,
                                      Custom = pdt.Custom,
                                      //Testing this one
                                      subscriberId = pdt.SubscriberId,
                                      //subscriberId = "",
                                      CustomerID = CustomerId,
                                      ProjectID = ProjectId
                                  };
                                  var PaymentID = int.Parse(Custom[2]);
                                  CustomerPaymentDue currentpaymentdue = (from c in context.CustomerPaymentDues
                                                        where c.PaymentDueID == PaymentID
                                                        select c).FirstOrDefault();

                                //Response.Write(pdt.PaymentStatus.ToString());
                                if (pdt.PaymentStatus == "Completed")
                                {
                                    //Archived PDT
                                    var archivedcustomerSuccessfulPDT = new ArchivedCustomerSuccessfulPDT
                                                                              {
                                                                                  PDTID = GetNextSuccessfulPDTID(),
                                                                                  GrossTotal = pdt.GrossTotal,
                                                                                  Invoice = pdt.InvoiceNumber,
                                                                                  PaymentStatus = pdt.PaymentStatus,
                                                                                  FirstName = pdt.PayerFirstName,
                                                                                  LastName = pdt.PayerLastName,
                                                                                  PaymentFee = pdt.PaymentFee,
                                                                                  BusinessEmail = pdt.BusinessEmail,
                                                                                  TxToken = Request.QueryString.Get("tx"),
                                                                                  ReceiverEmail = pdt.ReceiverEmail,
                                                                                  ItemName = pdt.ItemName,
                                                                                  CurrencyCode = pdt.Currency,
                                                                                  TransactionId = pdt.TransactionId,
                                                                                  Custom = pdt.Custom,
                                                                                  subscriberId = pdt.SubscriberId,
                                                                                  CustomerID = CustomerId,
                                                                                  ProjectID = ProjectId
                                                                              };
                                    context.AddToArchivedCustomerSuccessfulPDTs(archivedcustomerSuccessfulPDT);
                                    //Archived Payment Due
                                    var archivedpaymentdue = new ArchivedCustomerPayment
                                                                 {
                                                                     CustomerID = currentpaymentdue.CustomerID,
                                                                     PaymentDueID = currentpaymentdue.PaymentDueID,
                                                                     ProjectID = currentpaymentdue.ProjectID,
                                                                     ProjectAmount = currentpaymentdue.ProjectAmount,
                                                                     Date = currentpaymentdue.Date,
                                                                     StatusID = currentpaymentdue.StatusID,
                                                                     CurrencyCode = currentpaymentdue.CurrencyCode,
                                                                     PaymentDue = currentpaymentdue.PaymentDue,
                                                                     PhaseStatus = currentpaymentdue.PhaseStatus
                                                                 };
                                    context.AddToArchivedCustomerPayments(archivedpaymentdue);
                                    //Update PaymentDue
                                    context.CustomerPaymentDues.DeleteObject(currentpaymentdue);
                                    context.SaveChanges();

                                    //invoke timeup for customerpayment
                                    //Approve Ad
                                    //ApproveAd(AdID);
                                }
                                else
                                {
                                    currentpaymentdue.Status = pdt.PaymentStatus;
                                    currentpaymentdue.PaymentProcess = true;
                                }
                                context.AddToCustomerSuccessfulPDTs(CustomerSuccessfulPDT);
                                context.SaveChanges();
                            }
                            else
                            {
                                HiddenLabel.Text = Resources.Resource.AlreadyPaid;

                            }
                        }
                        catch (Exception e1)
                        {

                            string failuremessage = pdt.PayerFirstName + " " +
                                                    pdt.PayerLastName + "<br/>";
                            failuremessage += Resources.Resource.FailedTransaction + "<br/>";
                            failuremessage += Resources.Resource.FailurePDT;
                            HiddenLabel.Text = failuremessage;
                        }

                    }

                }
                else
                {
                    using (var context = new SidejobEntities())
                    {
                        try
                        {
                            string[] Custom = pdt.Custom.Split(',');
                            //var custom = GetProjectID() + "," + GetCustomerID() + "," + GetPaymentID();
                            int ProjectId = int.Parse(Custom[0]);
                            int CustomerId = int.Parse(Custom[1]);
                            int PaymentId = int.Parse(Custom[2]);

                            //Insert into HackedPDT
                            var CustomerHackedPDT = new CustomerHackedPDT
                                                          {
                                                                    PDTID = GetNextSuccessfulPDTID(),
                                                                    GrossTotal = pdt.GrossTotal,
                                                                    Invoice = pdt.InvoiceNumber,
                                                                    PaymentStatus = pdt.PaymentStatus,
                                                                    FirstName = pdt.PayerFirstName,
                                                                    LastName = pdt.PayerLastName,
                                                                    PaymentFee = pdt.PaymentFee,
                                                                    BusinessEmail = pdt.BusinessEmail,
                                                                    TxToken = Request.QueryString.Get("tx"),
                                                                    ReceiverEmail = pdt.ReceiverEmail,
                                                                    ItemName = pdt.ItemName,
                                                                    CurrencyCode = pdt.Currency,
                                                                    TransactionId = pdt.TransactionId,
                                                                    Custom = pdt.Custom,
                                                                    SubscriberId = pdt.SubscriberId,
                                                                    CustomerID = CustomerId,
                                                                    ProjectID = ProjectId
                                                          };
                            context.AddToCustomerHackedPDTs(CustomerHackedPDT);
                            context.SaveChanges();

                            //Email Admin
                            EmailAdmin("HackedPDT", GetNextSuccessfulPDTID());
                            string failuremessage = pdt.PayerFirstName + " " +
                                                    pdt.PayerFirstName + "<br/>";
                            failuremessage += Resources.Resource.FailedTransaction + "<br/>";
                            failuremessage += Resources.Resource.FailurePDT;
                            HiddenLabel.Text = failuremessage;
                        }
                        catch (Exception e1)
                        {
                            EmailAdmin("HackedPDT", GetNextSuccessfulPDTID());
                            string failuremessage = pdt.PayerFirstName + " " +
                                                    pdt.PayerFirstName + "<br/>";
                            failuremessage += Resources.Resource.FailedTransaction + "<br/>";
                            failuremessage += Resources.Resource.FailurePDT;
                            HiddenLabel.Text = failuremessage;
                        }
                    }
                }
            }
        }
Beispiel #30
0
    public void CustomerPayment(ClosedProject cp)
    {
        if (cp.HighestBid != null)
        {
            var projectPaymentDue = Math.Round((double)(GetPercentage((double)cp.HighestBid) * cp.HighestBid), 2);
            var phasemessage = "<b><font color='red'>" + Resources.Resource.Phase2 + ":</font></b><br>'" +
                               Resources.Resource.Project + " = "
                               + cp.HighestBid + "<br/>" + Resources.Resource.Fees + " = " + projectPaymentDue;

            var context = new SidejobEntities();
            if (cp.BidderID != null)
            {
                if (cp.CurrencyID != null)
                {
                    var customerpaymentdue = new CustomerPaymentDue
                    {
                        CustomerID = (int)cp.BidderID,
                        ProjectID = cp.ProjectID,
                        ProjectAmount = (double)cp.HighestBid,
                        Date = DateTime.Now.Date,
                        CurrencyCode = ScheduleMySide.Helpers.Utility.GetCurrencyCode((int)cp.CurrencyID),
                        PaymentDue = projectPaymentDue,
                        PhaseStatus = phasemessage
                    };
                    context.AddToCustomerPaymentDues(customerpaymentdue);
                }
                context.SaveChanges();
            }
        }
    }