public void AddDivision(CS_Division sourceDivision) { try { if (sourceDivision == null) _view.JobDivisionEntity.CS_Division = _view.DivisionValue; else _view.JobDivisionEntity.CS_Division = sourceDivision; if (null != _view.JobDivisionEntity) { if (!ContainsDivisionInList(_view.JobDivisionEntity.CS_Division.ID) && _view.JobDivisionEntity.CS_Division.ID != 0) { _view.JobDivisionEntity.Active = true; _view.JobDivisionEntity.CreatedBy = _view.CreatedBy; _view.JobDivisionEntity.CreationDate = DateTime.Now; _view.JobDivisionEntity.ModifiedBy = _view.CreatedBy; _view.JobDivisionEntity.ModificationDate = DateTime.Now; _view.JobDivisionEntityList.Add(_view.JobDivisionEntity); _view.ListJobDivision(); } else _view.DisplayMessage("The item already exists in the list or must be selected!", false); } else throw new Exception("The object containing the Division Information is null!"); } catch (Exception ex) { Logger.Write(string.Format("An error has ocurred while trying to add an item on the list!\n{0}\n{1}", ex.Message, ex.StackTrace)); _view.DisplayMessage("An error has ocurred while trying to add an item on the list.", false); } }
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 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 AddDivisionFromCustomerInfo(CS_Division division) { if (division != null && !(division.ID <= 0)) { if (!ContainsDivisionInList(division.ID)) { CS_JobDivision jobDivision = new CS_JobDivision(); CS_JobDivision removeAlreadySelectedDivision = null; jobDivision.CS_Division = division; foreach (var item in _view.JobDivisionEntityList) { if (item.IsFromCustomerInfo) removeAlreadySelectedDivision = item; item.PrimaryDivision = false; } if (removeAlreadySelectedDivision != null) { _view.JobDivisionEntityList.Remove(removeAlreadySelectedDivision); } jobDivision.IsFromCustomerInfo = true; jobDivision.DivisionID = jobDivision.CS_Division.ID; jobDivision.Active = true; jobDivision.CreatedBy = _view.CreatedBy; jobDivision.CreationDate = DateTime.Now; jobDivision.ModifiedBy = _view.CreatedBy; jobDivision.ModificationDate = DateTime.Now; jobDivision.PrimaryDivision = true; jobDivision.IsFromCustomerInfo = true; _view.JobDivisionEntityList.Add(jobDivision); _view.ListJobDivision(); } } }
/// <summary> /// Get the division actual from the current equipment /// </summary> private void GetDivisionActual(CS_Division division) { if (null != division) { _view.ActualEquipmentDivision = division.Name; } }
public void SetCallLogViewCallEntryRowData() { //Arrange FakeObjectSet<CS_FirstAlert> fakeFirstAlert = new FakeObjectSet<CS_FirstAlert>(); CS_FirstAlertType csFirstAlertType = new CS_FirstAlertType() { Active = true, Description = "injury", CreatedBy = "dcecilia", CreationDate = new DateTime(10, 10, 10, 5, 0, 1), ModifiedBy = "dcecilia", ModificationDate = new DateTime(10, 10, 10, 5, 0, 1), }; CS_FirstAlertFirstAlertType csFirstAlertFirstAlertType = new CS_FirstAlertFirstAlertType() { Active = true, FirstAlertID = 1, FirstAlertTypeID = 1, CreatedBy = "dcecilia", CreationDate = new DateTime(10, 10, 10, 5, 0, 1), ModifiedBy = "dcecilia", ModificationDate = new DateTime(10, 10, 10, 5, 0, 1), CS_FirstAlertType = csFirstAlertType }; EntityCollection<CS_FirstAlertFirstAlertType> entityCollectionFirstAlertFirstAlertType = new EntityCollection<CS_FirstAlertFirstAlertType>(); entityCollectionFirstAlertFirstAlertType.Add(csFirstAlertFirstAlertType); DateTime currentDate = DateTime.Now; CS_Customer csCustomer = new CS_Customer() { ID = 1, Active = true, Name = "Abcd", Country = "USA", CustomerNumber = "1000" }; CS_Job csJob = new CS_Job() { ID = 1, Active = true, CreatedBy = "dcecilia", CreationDate = currentDate, ModifiedBy = "dcecilia", ModificationDate = currentDate, Number = "123" }; CS_FirstAlert csFirstAlert = new CS_FirstAlert() { ID = 1, Active = true, Number = "123", JobID = 1, CS_Job = csJob, CustomerID = 1, CS_Customer = csCustomer, Details = "aaAaA", Date = currentDate, HasPoliceReport = true, CreatedBy = "dcecilia", CreationDate = currentDate, ModifiedBy = "dcecilia", ModificationDate = new DateTime(2011, 7, 12, 5, 0, 0), CS_FirstAlertFirstAlertType = entityCollectionFirstAlertFirstAlertType, }; CS_Division csDivision = new CS_Division() { Active = true, ID = 1, Name = "001" }; CS_FirstAlertDivision csFirstAlertDivision = new CS_FirstAlertDivision() { Active = true, ID = 1, FirstAlertID = 1, DivisionID = 1, CS_Division = csDivision, CS_FirstAlert = csFirstAlert }; Mock<IFirstAlertView> mock = new Mock<IFirstAlertView>(); mock.SetupProperty(c => c.FirstAlertRowDataItem, csFirstAlert); mock.SetupProperty(c => c.FirstAlertRowAlertDateAndTime, ""); mock.SetupProperty(c => c.FirstAlertRowAlertId, ""); mock.SetupProperty(c => c.FirstAlertRowAlertNumber, ""); mock.SetupProperty(c => c.FirstAlertRowCustomer, ""); mock.SetupProperty(c => c.FirstAlertRowDivision, ""); mock.SetupProperty(c => c.FirstAlertRowFirstAlertType, ""); mock.SetupProperty(c => c.FirstAlertRowJobNumber, ""); //Act FirstAlertViewModel viewModel = new FirstAlertViewModel(mock.Object); viewModel.SetDetailedFirstAlertRowData(); // Assert Assert.AreEqual(currentDate.ToString("MM/dd/yyyy") + " " + currentDate.ToShortTimeString(), mock.Object.FirstAlertRowAlertDateAndTime, "Failed in FirstAlertRowAlertDateAndTime"); Assert.AreEqual("1", mock.Object.FirstAlertRowAlertId, "Failed in FirstAlertRowAlertId"); Assert.AreEqual("123", mock.Object.FirstAlertRowAlertNumber, "Failed in FirstAlertRowAlertNumber"); Assert.AreEqual("Abcd - USA - 1000", mock.Object.FirstAlertRowCustomer, "Failed in FirstAlertRowCustomer"); Assert.AreEqual("001", mock.Object.FirstAlertRowDivision, "Failed in FirstAlertRowDivision"); Assert.AreEqual("injury", mock.Object.FirstAlertRowFirstAlertType, "Failed in FirstAlertRowFirstAlertType"); Assert.AreEqual("123", mock.Object.FirstAlertRowJobNumber, "Failed in FirstAlertRowJobNumber"); }
protected void ddlDivision_SelectedIndexChanged(object sender, EventArgs e) { actPOC.ContextKey = ddlDivision.SelectedValue; actPOC.FilterId = ddlDivision.SelectedValue; if (null != ViewState["DivisionValue"]) { if (ViewState["DivisionValue"].ToString() != ddlDivision.SelectedValue) { actPOC.SelectedText = string.Empty; actPOC.SelectedValue = string.Empty; } } if (DivisionChanged != null) { ViewState["DivisionValue"] = ddlDivision.SelectedValue; if (ddlDivision.SelectedValue == "0") { DivisionChanged(null); } else { CS_Division selectedDivision = new CS_Division(); selectedDivision.ID = int.Parse(ddlDivision.SelectedItem.Value); string[] divisioNameDescription = ddlDivision.SelectedItem.Text.Split('-'); selectedDivision.Name = divisioNameDescription[0].Trim(); selectedDivision.Description = divisioNameDescription[1].Trim(); DivisionChanged(selectedDivision); } } }
public void Initialize() { // Step 1 - Clear Tables JobInfoDao.Singleton.ClearAll(); ResourceDao.Singleton.ClearAll(); EmployeeDao.Singleton.ClearAll(); // Step 2 - Adding controlled data country = CountryDao.Singleton.Add( new CS_Country() { Active = true, Name = "USA", CreatedBy = "Load", CreationDate = DateTime.Now, ModifiedBy = "Load", ModificationDate = DateTime.Now }); state = StateDao.Singleton.Add( new CS_State() { Active = true, Acronym = "TX", Name = "Texas", CountryID = country.ID, CreatedBy = "Load", CreationDate = DateTime.Now, ModifiedBy = "Load", ModificationDate = DateTime.Now }); division = DivisionDao.Singleton.Add( new CS_Division() { Active = true, CountryID = country.ID, Description = "DIV1", StateID = state.ID, Name = "001", CreatedBy = "Load", CreationDate = DateTime.Now, ModifiedBy = "Load", ModificationDate = DateTime.Now }); employee1 = EmployeeDao.Singleton.Add( new CS_Employee() { Active = true, FirstName = "a", Name = "b", DivisionID = division.ID, BusinessCardTitle = "Laborer", CreatedBy = "Load", CreationDate = DateTime.Now, ModifiedBy = "Load", ModificationDate = DateTime.Now }); employee2 = EmployeeDao.Singleton.Add( new CS_Employee() { Active = true, FirstName = "c", Name = "d", DivisionID = division.ID, BusinessCardTitle = "Regional Vice President", CreatedBy = "Load", CreationDate = DateTime.Now, ModifiedBy = "Load", ModificationDate = DateTime.Now }); jobStatus = JobStatusDao.Singleton.Add( new CS_JobStatus() { Active = true, Description = "Active", CreatedBy = "Load", CreationDate = DateTime.Now, ModifiedBy = "Load", ModificationDate = DateTime.Now }); priceType = PriceTypeDao.Singleton.Add( new CS_PriceType() { Active = true, Acronym = "X", Description = "X", CreatedBy = "Load", CreationDate = DateTime.Now, ModifiedBy = "Load", ModificationDate = DateTime.Now }); jobCategory = JobCategoryDao.Singleton.Add( new CS_JobCategory() { Active = true, Description = "X", CreatedBy = "Load", CreationDate = DateTime.Now, ModifiedBy = "Load", ModificationDate = DateTime.Now }); jobType = JobTypeDao.Singleton.Add( new CS_JobType() { Active = true, Description = "X", CreatedBy = "Load", CreationDate = DateTime.Now, ModifiedBy = "Load", ModificationDate = DateTime.Now }); jobAction = JobActionDao.Singleton.Add( new CS_JobAction() { Active = true, Description = "X", CreatedBy = "Load", CreationDate = DateTime.Now, ModifiedBy = "Load", ModificationDate = DateTime.Now }); job = JobDao.Singleton.Add( new CS_Job() { Active = true, Number = "000001", CreatedBy = "Load", CreationDate = DateTime.Now, ModifiedBy = "Load", ModificationDate = DateTime.Now }); jobInfo = JobInfoDao.Singleton.Add( new CS_JobInfo() { Active = true, JobID = job.ID, JobStatusID = jobStatus.ID, PriceTypeID = priceType.ID, JobCategoryID = jobCategory.ID, JobTypeID = jobType.ID, JobActionID = jobAction.ID, InitialCallDate = DateTime.Now, InitialCallTime = new TimeSpan(0, 1, 10, 0, 0), InterimBill = false, ProjectManager = employee2.ID, EmployeeID = employee2.ID, CreatedBy = "Load", CreationDate = DateTime.Now, ModifiedBy = "Load", ModificationDate = DateTime.Now }); resource = ResourceDao.Singleton.Add( new CS_Resource() { Active = true, EmployeeID = employee1.ID, JobID = job.ID, CreatedBy = "Load", CreationDate = DateTime.Now, ModifiedBy = "Load", ModificationDate = DateTime.Now }); }
protected void uscCustomer_DivisionChanged(CS_Division divisionEntity) { uscJobInfo.DivisionFromExternalSource = divisionEntity; uscJobInfo.RefreshUpdatePanel(); }
public void IsSetJobCallLogDivisionRowDataFillingRowProperties() { // Arrange CS_Division divisionItem = new CS_Division() { ID = 1, Name = "001" }; Mock<IDashboardView> mock = new Mock<IDashboardView>(); mock.SetupProperty(c => c.DivisionRowName, ""); mock.SetupProperty(c => c.DivisionCount, 0); mock.SetupProperty(c => c.DivisionRepeaterDataItem, divisionItem); // Act DashboardViewModel viewModel = new DashboardViewModel(mock.Object); viewModel.SetJobCallLogDivisionRowData(); // Assert Assert.AreEqual("001", mock.Object.DivisionRowName, "Failed in DivisionRowName"); Assert.AreEqual(1, mock.Object.DivisionCount, "Failed in DivisionCount"); }