//on form submit - check user input against existing items //if editing, id is passed to ignore current item public bool IsAvailableTripTypeGroupName(string groupName, int?groupId) { TripTypeGroupDC dbTripTypeGroup = new TripTypeGroupDC(Settings.getConnectionString()); int count = 0; if (groupId.HasValue) { var result = from n in dbTripTypeGroup.TripTypeGroups where n.TripTypeGroupName.Trim().Equals(groupName) && n.TripTypeGroupId != groupId select n.TripTypeGroupName; count = result.Count(); } else { var result = from n in dbTripTypeGroup.TripTypeGroups where n.TripTypeGroupName.Trim().Equals(groupName) select n.TripTypeGroupName; count = result.Count(); } if (count == 0) { return(true); } else { return(false); } }
//Get List of Items attached to a Location (to populate LocationLinkedItemsVM) public void AddLinkedItems(LocationLinkedItemsVM locationLinkedItemsScreenViewModel) { int locationId = locationLinkedItemsScreenViewModel.Location.LocationId; HierarchyDC hierarchyDC = new HierarchyDC(Settings.getConnectionString()); locationLinkedItemsScreenViewModel.Addresses = (from n in hierarchyDC.LocationAddresses where n.LocationId == locationId select n.Address).ToList(); locationLinkedItemsScreenViewModel.Contacts = (from n in hierarchyDC.LocationContacts where n.LocationId == locationId select n.Contact).ToList(); ExternalSystemParameterDC externalSystemParameterDC = new ExternalSystemParameterDC(Settings.getConnectionString()); locationLinkedItemsScreenViewModel.ExternalSystemParameters = (from n in externalSystemParameterDC.ExternalSystemParameterLocations where n.LocationId == locationId select n.ExternalSystemParameter).ToList(); GDSAdditionalEntryDC gdsAdditionalEntryDC = new GDSAdditionalEntryDC(Settings.getConnectionString()); locationLinkedItemsScreenViewModel.GDSAdditionalEntries = (from n in gdsAdditionalEntryDC.GDSAdditionalEntryLocations where n.LocationId == locationId select n.GDSAdditionalEntry).ToList(); locationLinkedItemsScreenViewModel.CreditCards = (from n in hierarchyDC.CreditCardLocations where n.LocationId == locationId select n.CreditCard).ToList(); locationLinkedItemsScreenViewModel.QueueMinderGroups = (from n in hierarchyDC.QueueMinderGroupLocations where n.LocationId == locationId select n.QueueMinderGroup).ToList(); locationLinkedItemsScreenViewModel.ValidPseudoCityOrOfficeIds = (from n in hierarchyDC.LocationDefaultPseudoCityOrOfficeIds where n.LocationId == locationId select n.ValidPseudoCityOrOfficeId).ToList(); ServicingOptionGroupDC servicingOptionGroupDC = new ServicingOptionGroupDC(Settings.getConnectionString()); locationLinkedItemsScreenViewModel.ServicingOptionGroups = (from n in servicingOptionGroupDC.ServicingOptionGroupLocations where n.LocationId == locationId select n.ServicingOptionGroup).ToList(); TicketQueueGroupDC ticketQueueGroupDC = new TicketQueueGroupDC(Settings.getConnectionString()); locationLinkedItemsScreenViewModel.TicketQueueGroups = (from n in ticketQueueGroupDC.TicketQueueGroupLocations where n.LocationId == locationId select n.TicketQueueGroup).ToList(); TripTypeGroupDC tripTypeGroupDC = new TripTypeGroupDC(Settings.getConnectionString()); locationLinkedItemsScreenViewModel.TripTypeGroups = (from n in tripTypeGroupDC.TripTypeGroupLocations where n.LocationId == locationId select n.TripTypeGroup).ToList(); locationLinkedItemsScreenViewModel.PNROutputGroups = (from n in hierarchyDC.PNROutputGroupLocations where n.LocationId == locationId select n.PNROutputGroup).ToList(); PublicHolidayGroupDC publicHolidayGroupDC = new PublicHolidayGroupDC(Settings.getConnectionString()); locationLinkedItemsScreenViewModel.PublicHolidayGroups = (from n in publicHolidayGroupDC.PublicHolidayGroupLocations where n.LocationId == locationId select n.PublicHolidayGroup).ToList(); locationLinkedItemsScreenViewModel.WorkFlowGroups = (from n in hierarchyDC.WorkFlowGroupLocations where n.LocationId == locationId select n.WorkFlowGroup).ToList(); locationLinkedItemsScreenViewModel.Teams = (from n in hierarchyDC.TeamLocations where n.LocationId == locationId select n.Team).ToList(); locationLinkedItemsScreenViewModel.LocalOperatingHoursGroups = (from n in hierarchyDC.LocalOperatingHoursGroupLocations where n.LocationId == locationId select n.LocalOperatingHoursGroup).ToList(); PolicyGroupDC policyGroupDC = new PolicyGroupDC(Settings.getConnectionString()); locationLinkedItemsScreenViewModel.PolicyGroups = (from n in policyGroupDC.PolicyGroupLocations where n.LocationId == locationId select n.PolicyGroup).ToList(); }