public void GenerateEmailBodyForInvoicingTeamTest() { DateTime dt = new DateTime(2011, 02, 14); TimeSpan timeSpan = new TimeSpan(10, 11, 59); CS_Country country = new CS_Country() { ID = 1, Active = true, Name = "USA" }; CS_State state = new CS_State() { ID = 1, Active = true, Name = "Texas" }; CS_City city = new CS_City() { ID = 1, Active = true, Name = "Dalton" }; CS_LocationInfo locationInfo = new CS_LocationInfo() { Active = true, CountryID = 1, StateID = 1, CityID = 1, CS_Country = country, CS_State = state, CS_City = city }; CS_Frequency frequency = new CS_Frequency() { Active = true, ID = 1, Description = "D" }; CS_JobDescription csJobDescription = new CS_JobDescription() { Active = true, NumberEmpties = 1, NumberLoads = 2, NumberEngines = 1 }; CS_Division division = new CS_Division() { ID = 241, Active = true, Name = "005", Description = "White River, Ontario" }; CS_JobDivision jobdivision = new CS_JobDivision() { Active = true, JobID = 243, DivisionID = 241, CS_Division = division }; CS_Employee employee = new CS_Employee() { ID = 1, Active = true, Name = "Dcecilia", FirstName = "Test", DivisionID = 241 }; CS_Reserve reserve = new CS_Reserve() { Active = true, JobID = 243, Type = 2, CS_Employee = employee, DivisionID = 241 }; EntityCollection<CS_JobDivision> JobDivision = new EntityCollection<CS_JobDivision>(); JobDivision.Add(jobdivision); CS_ScopeOfWork csScopeOfWork = new CS_ScopeOfWork() { Active = true, ScopeOfWork = "xxcxcxc", JobId = 243 }; EntityCollection<CS_Reserve> csReserves = new EntityCollection<CS_Reserve>(); csReserves.Add(reserve); EntityCollection<CS_ScopeOfWork> scopeOfWorks = new EntityCollection<CS_ScopeOfWork>(); scopeOfWorks.Add(csScopeOfWork); //Arrange FakeObjectSet<CS_Job> fakeJobObject = new FakeObjectSet<CS_Job>(); fakeJobObject.AddObject ( new CS_Job() { ID = 243, Active = true, CreatedBy = "rbrandao", CreationDate = DateTime.Now, ModificationDate = DateTime.Now, ModifiedBy = "Load", //Internal_Tracking = "000000025INT", Number = "000243", CS_ScopeOfWork = scopeOfWorks, CS_JobDivision = JobDivision, CS_Reserve = csReserves, CS_CustomerInfo = new CS_CustomerInfo() { Active = true, CS_Customer = new CS_Customer() { Active = true, Name = "American Test" }, CS_Division = division, CS_Contact1 = new CS_Contact() { ID = 1, Active = true, Name = "danilo", LastName = "cecilia", }, CS_Contact3 = new CS_Contact() { ID = 1, Active = true, Name = "danilo", LastName = "cecilia", }, //IsCustomer = true, InitialCustomerContactId = 1, BillToContactId = 1 }, CS_JobInfo = new CS_JobInfo() { Active = true, InterimBill = true, CS_Employee = employee, EmployeeID = employee.ID, CS_Frequency = frequency, FrequencyID = 1, CS_JobAction = new CS_JobAction() { Active = true, Description = "Environmental Work, General - Undefined Scope of Work" }, CS_JobType = new CS_JobType() { Active = true, Description = "A" }, InitialCallDate = dt, InitialCallTime = timeSpan, CS_PriceType = new CS_PriceType() { Active = true, Acronym = "P", Description = "description test" }, CS_JobCategory = new CS_JobCategory() { Active = true, Description = "B" }, CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>() { new CS_Job_JobStatus() { Active = true, JobStatusId = (int)Globals.JobRecord.JobStatus.Active, JobStartDate = new DateTime(2011,02,14), JobCloseDate = new DateTime(2011,02,14) } } }, CS_LocationInfo = locationInfo, CS_JobDescription = csJobDescription } ); //Act Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>(); mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Job>()).Returns(fakeJobObject); JobModel jobModel = new JobModel(mockUnitOfWork.Object); string body = jobModel.GenerateEmailBodyForInvoicingTeam(243); StringBuilder sb = new StringBuilder(); sb.Append("<div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job#:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" PA000243"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Customer:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" American Test"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Initial Customer Contact:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" danilo"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Bill to:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" cecilia, danilo"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Initial Call date:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 02/14/2011"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Initial Call time:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 10:11:59"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Price Type:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" description test"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job Action:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Environmental Work, General - Undefined Scope of Work"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job Category:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" B"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job Type:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" A"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Division:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 005"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Interim Bill:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Yes"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Requested By:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Dcecilia, Test"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Frequency:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" D"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Country:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" USA"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("State:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Texas"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("City:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Dalton"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Engines:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 1"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Loads:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 2"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Empties:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 1"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Scope Of Work:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append("xxcxcxc"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job start date:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 02/14/2011 00:00:00"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job end date:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 02/14/2011 00:00:00"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("</div>"); //Assert Assert.AreEqual(sb.ToString(), body); }
public void GenerateEmailBodyForEstimationTeamTest() { DateTime dt = new DateTime(2011, 02, 14); CS_JobDescription csJobDescription = new CS_JobDescription() { Active = true, NumberEmpties = 1, NumberLoads = 2, NumberEngines = 1 }; CS_Division division = new CS_Division() { ID = 241, Active = true, Name = "005", Description = "White River, Ontario" }; CS_JobDivision jobdivision = new CS_JobDivision() { Active = true, JobID = 243, DivisionID = 241, CS_Division = division }; CS_Employee employee = new CS_Employee() { Active = true, Name = "Dcecilia", FirstName = "Test", DivisionID = 241 }; CS_Reserve reserve = new CS_Reserve() { Active = true, JobID = 243, Type = 2, CS_Employee = employee, DivisionID = 241 }; EntityCollection<CS_JobDivision> JobDivision = new EntityCollection<CS_JobDivision>(); JobDivision.Add(jobdivision); CS_ScopeOfWork csScopeOfWork = new CS_ScopeOfWork() { Active = true, ScopeOfWork = "xxcxcxc", JobId = 243 }; EntityCollection<CS_Reserve> csReserves = new EntityCollection<CS_Reserve>(); csReserves.Add(reserve); EntityCollection<CS_ScopeOfWork> scopeOfWorks = new EntityCollection<CS_ScopeOfWork>(); scopeOfWorks.Add(csScopeOfWork); //Arrange FakeObjectSet<CS_Job> fakeJobObject = new FakeObjectSet<CS_Job>(); fakeJobObject.AddObject ( new CS_Job() { ID = 243, Active = true, CreatedBy = "rbrandao", CreationDate = DateTime.Now, ModificationDate = DateTime.Now, ModifiedBy = "Load", Internal_Tracking = "000000025INT", CS_ScopeOfWork = scopeOfWorks, CS_JobDivision = JobDivision, CS_Reserve = csReserves, CS_CustomerInfo = new CS_CustomerInfo() { Active = true, CS_Customer = new CS_Customer() { Active = true, Name = "Test Customer" }, CS_Division = division }, CS_JobInfo = new CS_JobInfo() { Active = true, CS_JobAction = new CS_JobAction() { Active = true, Description = "Environmental Work, General - Undefined Scope of Work" }, CS_JobType = new CS_JobType() { Active = true, Description = "A" }, CS_PriceType = new CS_PriceType() { Active = true, Acronym = "P" }, CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>() { new CS_Job_JobStatus() { JobStatusId = (int)Globals.JobRecord.JobStatus.Bid, JobStartDate = new DateTime(2011,02,14), Active = true } } }, CS_JobDescription = csJobDescription } ); Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>(); mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Job>()).Returns(fakeJobObject); JobModel jobModel = new JobModel(mockUnitOfWork.Object); string body = jobModel.GenerateEmailBodyForEstimationTeam(243); StringBuilder sb = new StringBuilder(); sb.Append("<div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Proposal#:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" ##"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job#:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" PA000000025INT"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Customer:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Test Customer"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Division:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 005"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("JobType:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" A"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("JobAction:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Environmental Work, General - Undefined Scope of Work"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Scope Of Work:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append("xxcxcxc"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Job start date:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append("02/14/2011 00:00:00"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Employee:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" Dcecilia, Test"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Engines:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 1"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Loads:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 2"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div style='width: 100%; display: inline-block;'>"); sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>"); sb.Append("Number Empties:"); sb.Append("</b></div>"); sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>"); sb.Append(" 1"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("</div>"); Assert.AreEqual(sb.ToString(), body); }
public void SaveJobData() { if ((_view.InitialCallDate.Date + _view.InitialCallTime) > DateTime.Now) { _view.DisplayMessage("Initial Call Date can not be greater than today.", false); _view.SavedSuccessfuly = false; return; } // CS_Job CS_Job csJob = new CS_Job(); csJob.CreatedBy = _view.Username; csJob.CreationDate = DateTime.Now; csJob.ModifiedBy = _view.Username; csJob.ModificationDate = DateTime.Now; csJob.Active = true; csJob.EmergencyResponse = _view.IsEmergencyResponse; _jobModel.NewJob = csJob; // Validations for Hulcher Contact and Division //int? calledInByContactId = null; //if (_view.PrimaryContactId != null && _view.HulcherContactId != null) //{ // //calledInByContactId = _view.PrimaryContactId; // _view.PrimaryContactId = null; //} int? hulcherDivision = null; if (_view.HulcherContactId.HasValue) hulcherDivision = _view.PrimaryDivisionId; // CS_CustomerInfo CS_CustomerInfo customerInfo = new CS_CustomerInfo() { Active = true, InitialCustomerContactId = _view.PrimaryContactId, CustomerId = _view.CustomerId, PocEmployeeId = _view.HulcherContactId, DivisionId = hulcherDivision, CreatedBy = _view.Username, CreationDate = DateTime.Now, ModifiedBy = _view.Username, ModificationDate = DateTime.Now }; _jobModel.NewCustomer = customerInfo; // CS_JobDivision IList<CS_JobDivision> jobDivisionList = new List<CS_JobDivision>(); jobDivisionList.Add(new CS_JobDivision() { Active = true, CreatedBy = _view.Username, CreationDate = DateTime.Now, DivisionID = _view.PrimaryDivisionId, IsFromCustomerInfo = hulcherDivision.HasValue, ModificationDate = DateTime.Now, ModifiedBy = _view.Username, PrimaryDivision = true }); _jobModel.NewJobDivision = jobDivisionList; // CS_JobInfo CS_JobCategory jobCategory = _jobModel.GetJobCategoryByJobAction(_view.JobActionId); CS_JobType jobType = _jobModel.GetJobTypeByJobAction(_view.JobActionId); DateTime? startDate = null; DateTime? closedDate = null; if (_view.JobStatusId.Equals((int)Globals.JobRecord.JobStatus.Active)) startDate = DateTime.Now; else if (_view.JobStatusId.Equals((int)Globals.JobRecord.JobStatus.Closed)) closedDate = DateTime.Now; CS_JobInfo jobInfo = new CS_JobInfo() { Active = true, InitialCallDate = _view.InitialCallDate, InitialCallTime = _view.InitialCallTime, //JobStatusID = _view.JobStatusId, PriceTypeID = _view.PriceTypeId, JobActionID = _view.JobActionId, CreatedBy = _view.Username, CreationDate = DateTime.Now, ModifiedBy = _view.Username, ModificationDate = DateTime.Now, JobCategoryID = jobCategory.ID, JobTypeID = jobType.ID, }; _jobModel.NewJobInfo = jobInfo; CS_Job_JobStatus jobStatus = new CS_Job_JobStatus() { Active = true, CreatedBy = _view.Username, CreationDate = DateTime.Now, ModifiedBy = _view.Username, ModificationDate = DateTime.Now, JobStatusId = _view.JobStatusId, JobStartDate = startDate, JobCloseDate = closedDate }; _jobModel.NewJobStatusHistory = jobStatus; _jobModel.JobStatusID = _view.JobStatusId; if (_view.JobStatusId == (int)Globals.JobRecord.JobStatus.Active) _jobModel.NewJob.BillingStatus = (int)Globals.JobRecord.BillingStatus.Working; else if (_view.JobStatusId == (int)Globals.JobRecord.JobStatus.Closed || _view.JobStatusId == (int)Globals.JobRecord.JobStatus.Cancelled || _view.JobStatusId == (int)Globals.JobRecord.JobStatus.Lost) _jobModel.NewJob.BillingStatus = (int)Globals.JobRecord.BillingStatus.Done; else if (_view.JobStatusId == (int)Globals.JobRecord.JobStatus.Potential || _view.JobStatusId == (int)Globals.JobRecord.JobStatus.Preset || _view.JobStatusId == (int)Globals.JobRecord.JobStatus.PresetPurchase) _jobModel.NewJob.BillingStatus = (int)Globals.JobRecord.BillingStatus.Created; // CS_LocationInfo int countryId = _locationModel.GetCountryByStateId(_view.StateId); CS_LocationInfo locationInfo = new CS_LocationInfo() { Active = true, CountryID = countryId, StateID = _view.StateId, CityID = _view.CityId, ZipCodeId = _view.ZipCode, CreatedBy = _view.Username, CreationDate = DateTime.Now, ModifiedBy = _view.Username, ModificationDate = DateTime.Now }; _jobModel.NewLocationInfo = locationInfo; // CS_ScopeOfWork IList<CS_ScopeOfWork> lstScopeOfWork = new List<CS_ScopeOfWork>(); lstScopeOfWork.Add(new CS_ScopeOfWork() { Active = true, ScopeOfWork = _view.ScopeOfWork, CreatedBy = _view.Username, CreationDate = DateTime.Now, ModifiedBy = _view.Username, ModificationDate = DateTime.Now }); _jobModel.NewScopeOfWork = lstScopeOfWork; // CS_JobDescription CS_JobDescription jobDescription = new CS_JobDescription() { Active = true, CreatedBy = _view.Username, CreationDate = DateTime.Now, ModifiedBy = _view.Username, ModificationDate = DateTime.Now }; _jobModel.NewJobDescription = jobDescription; _jobModel.SaveJobData(false, null, true); _view.JobId = _jobModel.NewJob.ID; _view.SavedSuccessfuly = true; }