// Converts a dynamics entity into a view model public static LicenceEvent ToViewModel(this MicrosoftDynamicsCRMadoxioEvent item, IDynamicsClient dynamicsClient) { LicenceEvent result = null; if (item != null) { result = new LicenceEvent(); if (item.AdoxioEventid != null) { result.Id = item.AdoxioEventid; } result.Status = (LicenceEventStatus?)item.Statuscode; result.Name = item.AdoxioName; result.StartDate = item.AdoxioEventstartdate; result.EndDate = item.AdoxioEventenddate; result.VenueDescription = item.AdoxioVenuenamedescription; result.AdditionalLocationInformation = item.AdoxioAdditionallocationinfo; result.FoodService = (FoodService?)item.AdoxioFoodservice; result.FoodServiceDescription = item.AdoxioFoodservicedescription; result.Entertainment = (Entertainment?)item.AdoxioEntertainment; result.EntertainmentDescription = item.AdoxioEntertainmentdescription; result.ContactPhone = item.AdoxioContactphonenumber; result.ExternalId = item.AdoxioExternalid; result.ContactName = item.AdoxioContactname; result.ContactEmail = item.AdoxioContactemail; result.EventNumber = item.AdoxioEventnumber; result.ClientHostname = item.AdoxioClienthostname; result.EventType = (EventType?)item.AdoxioEventtype; result.EventTypeDescription = item.AdoxioEventdescription; result.ImportSequenceNumber = item.Importsequencenumber; result.SpecificLocation = (SpecificLocation?)item.AdoxioSpecificlocation; result.EventClass = (EventClass?)item.AdoxioClass; result.MaxAttendance = item.AdoxioMaxattendance; result.MaxStaffAttendance = item.AdoxioMaxstaffattendance; result.MinorsAttending = item.AdoxioAttendanceminors; result.CommunityApproval = item.AdoxioCommunityapproval; result.NotifyEventInspector = item.AdoxioNotifyeventinspector; result.LicenceId = item._adoxioLicenceValue; result.AccountId = item._adoxioAccountValue; result.Street1 = item.AdoxioStreet1; result.Street2 = item.AdoxioStreet2; result.City = item.AdoxioCity; result.Province = item.AdoxioProvince; result.PostalCode = item.AdoxioPostalcode; result.ModifiedOn = item.Modifiedon; result.Schedules = new List <LicenceEventSchedule>(); // Security Plan result.SecurityPlanRequested = item.AdoxioRequestsafetysecurityplan; result.EventLiquorLayout = item.AdoxioEventliquorlayout; result.DailyEventAttendees = item.AdoxioNumberdailyeventattendees; result.DailyMinorAttendees = item.AdoxioNumberdailyminorattendees; result.OccupantLoad = item.AdoxioEventoccupantload; result.OccupantLoadAvailable = item.AdoxioIseventloadavailable; result.OccupantLoadServiceArea = item.AdoxioEventoccupantloadservicesarea; result.OccupantLoadServiceAreaAvailable = item.AdoxioIsservicearealoadavailable; result.ServiceAreaControlledDetails = item.AdoxioEventliquorcontainment; result.StaffingManagers = item.AdoxioEventstaffingmanagers; result.StaffingBartenders = item.AdoxioEventstaffingbartenders; result.StaffingServers = item.AdoxioEventstaffingservers; result.SecurityPersonnel = item.AdoxioSecuritycompanysummary; result.SecurityPersonnelThroughCompany = item.AdoxioSecuritypersonnelnumberhired; result.SecurityCompanyName = item.AdoxioSecuritycompanyname; result.SecurityCompanyAddress = item.AdoxioSecuritycompanystreet; result.SecurityCompanyCity = item.AdoxioSecuritycompanycity; result.SecurityCompanyPostalCode = item.AdoxioSecuritycompanypostal; result.SecurityCompanyContactPerson = item.AdoxioSecuritycompanycontactname; result.SecurityCompanyPhoneNumber = item.AdoxioSecuritycompanycontactphone; result.SecurityCompanyEmail = item.AdoxioSecuritycompanycontactemail; result.SecurityPoliceOfficerSummary = item.AdoxioPoliceofficersummary; result.SafeAndResponsibleMinorsNotAttending = item.AdoxioIsminorsattending; result.SafeAndResponsibleLiquorAreaControlled = item.AdoxioIsliquorareacontrolled; result.SafeAndResponsibleLiquorAreaControlledDescription = item.AdoxioLiquorareacontrolleddetails; result.SafeAndResponsibleMandatoryID = item.AdoxioIstwopiecesidrequired; result.SafeAndResponsibleSignsAdvisingMinors = item.AdoxioIssignsadvisingminors; result.SafeAndResponsibleMinorsOther = item.AdoxioIsotherminorssafety; result.SafeAndResponsibleMinorsOtherDescription = item.AdoxioIsotherminorssafetydetails; result.SafeAndResponsibleSignsAdvisingRemoval = item.AdoxioIssignsintoxicatedpersons; result.SafeAndResponsibleSignsAdvisingTwoDrink = item.AdoxioIssignstwodrinkmax; result.SafeAndResponsibleOverConsumptionOther = item.AdoxioIsotherconsumptionsafety; result.SafeAndResponsibleOverConsumptionOtherDescription = item.AdoxioIsotherconsumptionsafetydetails; result.SafeAndResponsibleReadAppendix2 = item.AdoxioIsdisturbanceappendix2; result.SafeAndResponsibleDisturbancesOther = item.AdoxioIsotherdisturbance; result.SafeAndResponsibleDisturbancesOtherDescription = item.AdoxioIsotherdisturbancedetails; result.SafeAndResponsibleAdditionalSafetyMeasures = item.AdoxioAdditionalsafetydetails; result.SafeAndResponsibleServiceAreaSupervision = item.AdoxioServiceareaentrancesupervisiondetails; result.DeclarationIsAccurate = item.AdoxioIsdeclarationaccurate; result.SecurityPlanSubmitted = item.AdoxioSafetysecurityplanchangessubmitted; result.SEPLicensee = item.AdoxioSeplicensee; result.SEPLicenceNumber = item.AdoxioSeplicencenumber; result.SEPContactName = item.AdoxioSepcontactname; result.SEPContactPhoneNumber = item.AdoxioSepcontactphonenumber; //market events result.IsNoPreventingSaleofLiquor = item.AdoxioIsnopreventingsaleofliquor; result.IsMarketManagedorCarried = item.AdoxioIsmarketmanagedorcarried; result.IsMarketOnlyVendors = item.AdoxioIsmarketonlyvendors; result.IsNoImportedGoods = item.AdoxioIsnoimportedgoods; result.IsMarketHostsSixVendors = item.AdoxioIsmarkethostssixvendors; result.IsMarketMaxAmountorDuration = item.AdoxioIsmarketmaxamountorduration; result.MKTOrganizerContactName = item.AdoxioMktorganizercontactname; result.MKTOrganizerContactPhone = item.AdoxioMktorganizercontactphone; result.RegistrationNumber = item.AdoxioRegistrationnumber; result.BusinessNumber = item.AdoxioBusinessnumber; result.MarketName = item.AdoxioMarketname; result.MarketWebsite = item.AdoxioMarketwebsite; result.MarketDuration = (MarketDuration?)item.AdoxioMarketduration; result.IsAllStaffServingitRight = item.AdoxioIsallstaffservingitright; result.IsSalesAreaAvailandDefined = item.AdoxioIssalesareaavailanddefined; result.IsSampleSizeCompliant = item.AdoxioIssamplesizecompliant; result.EventCategory = (EventCategory?)item.AdoxioEventcategory; result.MarketEventType = (MarketEventType?)item.AdoxioMarketeventtype; // temporary use area (TUA) events result.EventName = item.AdoxioEventname; result.TuaEventType = (TuaEventType?)item.AdoxioTuaeventtype; result.IsClosedToPublic = item.AdoxioIsclosedtopublic; result.IsWedding = item.AdoxioIswedding; result.IsNetworkingParty = item.AdoxioIsnetworkingparty; result.IsConcert = item.AdoxioIsconcert; result.IsBanquet = item.AdoxioIsbanquet; result.IsAmplifiedSound = item.AdoxioIsamplifiedsound; result.IsDancing = item.AdoxioIsdancing; result.IsReception = item.AdoxioIsreception; result.IsLiveEntertainment = item.AdoxioIsliveentertainment; result.IsGambling = item.AdoxioIsgambling; result.IsNoneOfTheAbove = item.AdoxioIsnoneoftheabove; result.IsAgreement1 = item.AdoxioIsagreement1; result.IsAgreement2 = item.AdoxioIsagreement2; result.EventLocations = new List <LicenceEventLocation>(); } MicrosoftDynamicsCRMadoxioEventscheduleCollection eventSchedules = dynamicsClient.GetEventSchedulesByEventId(result.Id); foreach (var schedule in eventSchedules.Value) { result.Schedules.Add(schedule.ToViewModel()); } // TUA event locations MicrosoftDynamicsCRMadoxioEventlocationCollection eventLocations = dynamicsClient.GetEventLocationsByEventId(result.Id); foreach (var loc in eventLocations?.Value) { result.EventLocations.Add(loc.ToViewModel()); } return(result); }