Пример #1
0
    public void UpdatePendingProject(SidejobEntities context)
    {
        var t = (from c in context.Projects
                 where c.StatusInt == 2
                 select c).ToList();
        foreach (var t1 in t)
        {
            var exist = (from c in context.PendingProjects
                         where c.ProjectID == t1.ProjectID
                         select c).ToList();
            if (exist.Count == 0)
            {
                var existprojectrequirement = (from c in context.ProjectRequirements
                                               where c.ProjectID == t1.ProjectID
                                               select c).FirstOrDefault();
                if (existprojectrequirement != null)
                {
                    var newpendingproject = new PendingProject
                                                {

                                                    ProjectID = existprojectrequirement.ProjectID,
                                                    LCID = existprojectrequirement.LCID,
                                                    JobTitle = existprojectrequirement.JobTitle,
                                                    StartDate = existprojectrequirement.StartDate,
                                                    EndDate = existprojectrequirement.EndDate,
                                                    Description = existprojectrequirement.Description,
                                                    SpecialNotes = existprojectrequirement.SpecialNotes,
                                                    Address = existprojectrequirement.Address,
                                                    DatePosted = existprojectrequirement.DatePosted
                                                };
                    context.AddToPendingProjects(newpendingproject);
                    context.SaveChanges();
                }
            }
        }
    }