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 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 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());
                }

            }
        }
 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 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.MessageID.ToString(CultureInfo.InvariantCulture));
                    context.DeleteObject(m);
                }
                catch (Exception)
                {
                    CatchMessage(context, m);
                }
            }
        }
    }
 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();
         }
     }
 }
Beispiel #10
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();
 }
Beispiel #11
0
 public void ProWin(Bid bidder)
 {
     var context = new SidejobEntities();
     var professionalwinbid = new ProfessionalWinBid
     {
         BidID = bidder.BidID,
         ProID = bidder.BidderID,
         NumberofBids = GetProfessionalNumberofBids(bidder.BidderID)
     };
     context.AddToProfessionalWinBids(professionalwinbid);
     context.DeleteObject(bidder);
     context.SaveChanges();
 }
 public static void PosterResponseDelayUpdate(int projectid)
 {
     using (var context = new SidejobEntities())
     {
         var rd = (from c in context.ResponseDelays
                   where c.ProjectID == projectid
                   select c).FirstOrDefault();
         context.DeleteObject(rd);
     }
 }
    private void Process()
    {
        using (var context = new SidejobEntities())
        {

            var newopportunity = (from cp in context.ProjectSecondChances
                                  where cp.ProjectID == ProjectID
                                  select cp);
            if (newopportunity.Count() == 2)
            {

                //Save to ArchivedProjectSecondChance
                SavedToArchivedProjectSecondChance(context, newopportunity);

                //Delete Previous BidderWin and Bids
                DeletePreviousBidderWin(context, ProjectID);

                //Add Current BidderWin
                AddNewBidderWin(context, ProjectID);

                //update project
                Updateproject(context);

                //delete from Response Delay
                DeleteFromResponseDelay(context);

                foreach (ProjectSecondChance o in newopportunity.ToList())
                {
                    context.DeleteObject(o);
                }
            }

            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();
            }
        }
        public void ArchiveCancelledProject(SidejobEntities context)
        {
            //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);
            context.SaveChanges();
        }
 private void MessageProperties()
 {
     //GET THE PDTID FORM ARCHIVE REFUND
     const string singlespace = " ";
     const string startofBoldRed = "<span class='DarkRed'><strong>";
     const string lastofBoldRed = "</strong></span>";
     PDTID = Convert.ToInt32(Request.QueryString["pdtid"]);
     ProjectID = Convert.ToInt32(Request.QueryString["prid"]);
     ProfessionalID = Convert.ToInt32(Request.QueryString["pid"]);
     if (ProjectID == 0) return;
     ProjectNotification.Text = Resources.Resource.Project + singlespace + ProjectID + singlespace +
                                Resources.Resource.Notification;
     ConfirmationEmail.Text = Resources.Resource.RefundEmailMessage1 + singlespace
                              + startofBoldRed + ProjectID + lastofBoldRed + singlespace +
                              Resources.Resource.RefundEmailMessage2;
     using (var context = new SidejobEntities())
     {
         var currentrefund = (from c in context.RefundProfessionalSuccessfulPDTs
                              where c.PDTID == PDTID
                              select c).FirstOrDefault();
         if (currentrefund == null) return;
         Amount.Text = currentrefund.GrossTotal.ToString(CultureInfo.InvariantCulture) +
                       singlespace + currentrefund.CurrencyCode.ToString(CultureInfo.InvariantCulture) + singlespace;
         Transaction.Text = currentrefund.TransactionId;
         NameLabel.Text = currentrefund.FirstName + singlespace + currentrefund.LastName;
         context.DeleteObject(currentrefund);
         context.SaveChanges();
     }
 }
Beispiel #17
0
    public void CleanProjectData(SidejobEntities context)
    {
        var cp = (from c in context.ClosedProjects
                  where c.ProjectID == ProjectID
                  select c).ToList();
        if (cp.Count != 0)
        {
            foreach (var ccp in cp)
            {
                context.DeleteObject(ccp);
            }
        }
        context.SaveChanges();

        var rd = (from c in context.ResponseDelays
                  where c.ProjectID == ProjectID
                  select c).ToList();
        if (rd.Count != 0)
        {
            foreach (var crd in rd)
            {
                context.DeleteObject(crd);
            }
        }
        context.SaveChanges();
    }
Beispiel #18
0
    public void UpdateResponseDelay(int action, ClosedProject cp, SidejobEntities context)
    {
        if (action == 0) return;
        switch (action)
        {
            case 1:
                var rd = new ResponseDelay
                             {
                                 BidderID = BidderID,
                                 CurrencyID = cp.CurrencyID,
                                 BidderRole = BidderRole,
                                 DateFinished = DateTime.UtcNow.Date,
                                 HighestBid = cp.HighestBid,
                                 PosterID = PosterID,
                                 ReminderLevel = 1,
                                 Status = 3
                             };
                context.AddToResponseDelays(rd);
                context.SaveChanges();
                break;

            case 2:
                var rd2 = (from c in context.ResponseDelays
                           where c.BidderID == BidderID
                                 && c.PosterID == PosterID && c.Status == 3
                           select c).FirstOrDefault();
                if (rd2 != null)
                {
                    rd2.Status = 4;
                    context.SaveChanges();
                }
                break;

            case 3:
                ArchiveProject(context);
                var rd3 = (from c in context.ResponseDelays
                           where c.BidderID == BidderID
                                 && c.PosterID == PosterID
                           select c).FirstOrDefault();
                if (rd3 != null)
                {
                    context.DeleteObject(rd3);
                    context.DeleteObject(cp);
                    var p = (from c in context.Projects
                             where c.ProjectID == ProjectID
                             select c).FirstOrDefault();
                    if (p != null)
                    {
                        p.StatusInt = 6;
                        context.SaveChanges();
                    }

                }
                break;
        }
    }
    public void DeletePreviousBidderWin(SidejobEntities context, int projectId)
    {
        var previous = (from c in context.ClosedProjects
                        where c.ProjectID == projectId
                        select c.BidderID).FirstOrDefault();

        if (previous != null)
        {
            var bids = (from c in context.Bids
                        where c.ProjectID == projectId && c.BidderID == previous
                        orderby c.AmountOffered descending
                        select c).FirstOrDefault();

            if (bids != null)
            {
                int previousbidid = bids.BidID;
                context.DeleteObject(bids);
                var previouswinnerbid = (from c in context.ProfessionalWinBids
                                         where c.ProID == previous
                                         && c.BidID == previousbidid
                                         select c).FirstOrDefault();
                if (previouswinnerbid != null)
                {
                    context.DeleteObject(previouswinnerbid);
                }

            }

            context.SaveChanges();
        }
    }
 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();
         }
     }
 }
        /// <summary>
        /// Delete All References to this project
        /// </summary>
        public void CleanUpProjectReferences(SidejobEntities context)
        {
            //ProjectSecondChance
            //ClosedProject
            //ResponseDelay
            //Bids

            //// Archives ////
            /////Cancelled////
            //////Project/////
            //// Archives ////

            //ProfessionalWinBid

            CleanUpTables(context, (from c in context.ProjectSecondChances where c.ProjectID == ProjectID select c).ToList());
            CleanUpTables(context, (from c in context.ClosedProjects where c.ProjectID == ProjectID select c).ToList());
            CleanUpTables(context, (from c in context.ResponseDelays where c.ProjectID == ProjectID select c).ToList());
            CleanUpTables(context, (from c in context.Bids where c.ProjectID == ProjectID &&  c.BidderID == BidderID select c).ToList());
            ArchiveCancelledProject(context);
            var pwb = (from c in context.ProfessionalWinBids
                           where c.ProID == BidderID
                           select c).FirstOrDefault();
            if (pwb == null) return;
            context.DeleteObject(pwb);
            context.SaveChanges();
        }
    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////////////////////////////
            }
        }
    }
 private static void CleanUpTables(SidejobEntities context, ICollection entityList)
 {
     if (entityList.Count <= 0) return;
     foreach (var item in entityList)
     {
         context.DeleteObject(item);
         context.SaveChanges();
     }
 }
    private void DeletePreviousBidderWin(SidejobEntities context, int projectId)
    {
        var previous = (from c in context.ClosedProjects
                        where c.ProjectID == projectId
                        select c.PosterID).FirstOrDefault();

        if (previous != 0)
        {
            var bids = (from c in context.Bids
                        where c.ProjectID == projectId && c.BidderID == previous
                        orderby c.AmountOffered
                        select c).FirstOrDefault();

            if (bids != null)
            {
                int previousbidid = bids.BidID;
                var previouswinnerbid = from c in context.ProfessionalWinBids
                                        where c.ProID == previous
                                        && c.BidID == previousbidid
                                        select c;

                context.DeleteObject(bids);
                context.DeleteObject(previouswinnerbid);
            }
        }
    }
    private void Updateproject(SidejobEntities context)
    {
        //Delete From ClosedProject
        var closedproject = (from c in context.ClosedProjects
                             where c.ProjectID == ProjectID
                             select c).FirstOrDefault();
        if (closedproject != null)
        {
            context.DeleteObject(closedproject);
        }

        //Update Project Requirement End Date to Today
        var projectrequirement = (from c in context.ProjectRequirements
                                  where c.ProjectID == ProjectID
                                  select c).FirstOrDefault();
        if (projectrequirement != null)
        {
            projectrequirement.EndDate = DateTime.Now.Date;
            projectrequirement.AmountOffered = (double)GetCurrentNewBid(ProjectID, NewProID).AmountOffered;
            context.SaveChanges();
        }

        //Update HighestBid and BidderID
        var project = (from c in context.Projects
                       where c.ProjectID == ProjectID
                       select c).FirstOrDefault();
        if (project != null)
        {
            project.HighestBid = GetCurrentNewBid(ProjectID, NewProID).AmountOffered;
            project.HighestBidderID = NewProID;
            project.HighestBidUsername = GetProfessional().UserName;
            project.StatusInt = 0;
            context.SaveChanges();
        }
    }