示例#1
0
    public static void Contract(ProfessionalGeneral professionalbidder, CustomerGeneral customerposter, ClosedProject cp)
    {
        var context = new SidejobEntities();
        var project = (from c in context.ProjectRequirements
                       where c.ProjectID == cp.ProjectID
                       select c).FirstOrDefault();

        if (project != null)
        {
            var contract = new Contract
            {
                ContractID = GetNextContractID(),
                ProjectID = cp.ProjectID,
                ContractDate = DateTime.Now.Date,
                BidderID = customerposter.CustomerID,
                BidderRole = "CUS",
                BidderUsername = customerposter.UserName,
                BidderFirstName = customerposter.FirstName,
                BidderLastName = customerposter.LastName,
                BidderAddress = customerposter.Address,
                BidderCountryID = customerposter.CountryID,
                BidderCountryName = customerposter.CountryName,
                BidderRegionID = customerposter.RegionID,
                BidderRegionName = customerposter.RegionName,
                BidderHomePhoneNumber = customerposter.HomePhoneNumber,
                PosterID = professionalbidder.ProID,
                PosterRole = "PRO",
                PosterUsername = professionalbidder.UserName,
                PosterFirstName = professionalbidder.FirstName,
                PosterLastName = professionalbidder.LastName,
                PosterAddress = professionalbidder.Address,
                PosterCountryID = professionalbidder.CountryID,
                PosterCountryName = professionalbidder.CountryName,
                PosterRegionID = professionalbidder.RegionID,
                PosterRegionName = professionalbidder.RegionName,
                PosterZipcode = professionalbidder.Zipcode,
                LCID = project.LCID,
                ProjectCategoryID = project.CategoryID,
                ProjectCategoryName = project.CategoryName,
                ProjectJobID = project.JobID,
                ProjectExperienceID = project.ExperienceID,
                ProjectCrewNumberID = project.CrewNumberID,
                ProjectLicensedID = project.LicensedID,
                ProjectInsuredID = project.InsuredID,
                ProjectRelocationID = project.RelocationID,
                ProjectStartDate = project.StartDate,
                ProjectEndDate = project.EndDate,
                ProjectAddress = project.Address,
                ProjectCountryID = project.CountryID,
                ProjectCountryName = project.CountryName,
                ProjectRegionID = project.RegionID,
                ProjectRegionName = project.RegionName,
            };
            context.AddToContracts(contract);
        }
    }