public void Initialize() { //DatabaseTestClass.TestService.GenerateData(); _customerInfo = new CS_CustomerInfo() { }; }
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; }
public void TestIfSubjectIsCorrect() { // Arrange CS_JobInfo jobInfo = new CS_JobInfo() { JobID = 2, CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>() { new CS_Job_JobStatus() { ID = 1, JobID = 2, JobStatusId = 1, Active = true } }, CS_PriceType = new CS_PriceType() { ID = 1, Acronym = "P", Active = true }, CS_JobType = new CS_JobType() { ID = 1, Description = "C", Active = true }, CS_JobAction = new CS_JobAction() { ID = 1, Description = "Action", Active = true } }; CS_Job job = new CS_Job() { ID = 2, Number = "000001", Active = true, CS_JobInfo = jobInfo }; CS_CustomerInfo customerInfo = new CS_CustomerInfo() { JobId = 2, CS_Customer = new CS_Customer() { ID = 1, Name = "Customer Name", Active = true } }; CS_LocationInfo locationInfo = new CS_LocationInfo() { JobID = 2, CS_City = new CS_City() { ID = 1, Name = "City", Active = true }, CS_State = new CS_State() { ID = 1, Acronym = "ST", Active = true } }; string callType = "Call Type Description"; // Act CallCriteriaModel model = new CallCriteriaModel(); string result = model.GenerateSubjectForCallCriteria(job, jobInfo, customerInfo, locationInfo, callType); // Assert string expectedResult = "PC000001, Customer Name, Action, City ST, Call Type Description"; Assert.AreEqual(expectedResult, result); }
/// <summary> /// Generates the Subject for the email that needs to be sent by the Call Criteria Process /// </summary> /// <param name="job">Job Details</param> /// <param name="jobInfo">Job Info Details</param> /// <param name="customerInfo">Customer Info Details</param> /// <param name="locationInfo">Location Info Details</param> /// <param name="callType">Call Type</param> /// <returns>Email Subject</returns> public string GenerateSubjectForCallCriteria(CS_Job job, CS_JobInfo jobInfo, CS_CustomerInfo customerInfo, CS_LocationInfo locationInfo, string callType) { string subject = string.Empty; if (job.ID == Globals.GeneralLog.ID) subject = string.Format("{0} - General Log - {1}", job.Number, callType); else { if (null != job) subject = string.Format("{0}, {1}, {2}, {3} {4}, {5}", job.PrefixedNumber, customerInfo.CS_Customer.Name.Trim(), jobInfo.CS_JobAction.Description, locationInfo.CS_City.Name, locationInfo.CS_State.Acronym, callType); } return subject; }