public async static Task <ViewModels.Application> ToViewModel(this MicrosoftDynamicsCRMadoxioApplication dynamicsApplication, IDynamicsClient dynamicsClient, IMemoryCache cache, ILogger logger)
        {
            ViewModels.Application applicationVM = new ViewModels.Application()
            {
                Name      = dynamicsApplication.AdoxioName,
                JobNumber = dynamicsApplication.AdoxioJobnumber,
                //get establishment name and address
                EstablishmentName              = dynamicsApplication.AdoxioEstablishmentpropsedname,
                EstablishmentAddressStreet     = dynamicsApplication.AdoxioEstablishmentaddressstreet,
                EstablishmentAddressCity       = dynamicsApplication.AdoxioEstablishmentaddresscity,
                EstablishmentAddressPostalCode = dynamicsApplication.AdoxioEstablishmentaddresspostalcode,
                EstablishmentAddress           = dynamicsApplication.AdoxioEstablishmentaddressstreet
                                                 + ", " + dynamicsApplication.AdoxioEstablishmentaddresscity
                                                 + " " + dynamicsApplication.AdoxioEstablishmentaddresspostalcode,
                EstablishmentPhone    = dynamicsApplication.AdoxioEstablishmentphone,
                EstablishmentEmail    = dynamicsApplication.AdoxioEstablishmentemail,
                FederalProducerNames  = dynamicsApplication.AdoxioFederalproducernames,
                IsApplicationComplete = (GeneralYesNo?)dynamicsApplication.AdoxioIsapplicationcomplete,

                RenewalCriminalOffenceCheck     = (ValueNotChanged?)dynamicsApplication.AdoxioRenewalcriminaloffencecheck,
                RenewalUnreportedSaleOfBusiness = (ValueNotChanged?)dynamicsApplication.AdoxioRenewalunreportedsaleofbusiness,
                RenewalBusinessType             = (ValueNotChanged?)dynamicsApplication.AdoxioRenewalbusinesstype,
                RenewalTiedhouse            = (ValueNotChanged?)dynamicsApplication.AdoxioRenewaltiedhouse,
                RenewalOrgLeadership        = (ValueNotChanged?)dynamicsApplication.AdoxioRenewalorgleadership,
                Renewalkeypersonnel         = (ValueNotChanged?)dynamicsApplication.AdoxioRenewalkeypersonnel,
                RenewalShareholders         = (ValueNotChanged?)dynamicsApplication.AdoxioRenewalshareholders,
                RenewalOutstandingFines     = (ValueNotChanged?)dynamicsApplication.AdoxioRenewaloutstandingfines,
                RenewalBranding             = (ValueNotChanged?)dynamicsApplication.AdoxioRenewalbranding,
                RenewalSignage              = (ValueNotChanged?)dynamicsApplication.AdoxioRenewalsignage,
                RenewalEstablishmentAddress = (ValueNotChanged?)dynamicsApplication.AdoxioRenewalestablishmentaddress,
                RenewalValidInterest        = (ValueNotChanged?)dynamicsApplication.AdoxioRenewalvalidinterest,
                RenewalZoning            = (ValueNotChanged?)dynamicsApplication.AdoxioRenewalzoning,
                RenewalFloorPlan         = (ValueNotChanged?)dynamicsApplication.AdoxioRenewalfloorplan,
                RenewalSiteMap           = (ValueNotChanged?)dynamicsApplication.AdoxioRenewalsitemap,
                TiedhouseFederalInterest = (ValueNotChanged?)dynamicsApplication.AdoxioRenewaltiedhousefederalinterest,
                RenewalDUI        = (ValueNotChanged?)dynamicsApplication.AdoxioRenewaldui,
                RenewalThirdParty = (ValueNotChanged?)dynamicsApplication.AdoxioRenewalthirdparty,

                AuthorizedToSubmit = dynamicsApplication.AdoxioAuthorizedtosubmit,
                SignatureAgreement = dynamicsApplication.AdoxioSignatureagreement,

                LicenceFeeInvoicePaid = (dynamicsApplication.AdoxioLicencefeeinvoicepaid != null && dynamicsApplication.AdoxioLicencefeeinvoicepaid == true),

                // set a couple of read-only flags to indicate status
                IsPaid = (dynamicsApplication.AdoxioPaymentrecieved != null && (bool)dynamicsApplication.AdoxioPaymentrecieved),

                IndigenousNationId   = dynamicsApplication._adoxioLocalgovindigenousnationidValue,
                PoliceJurisdictionId = dynamicsApplication._adoxioPolicejurisdictionidValue,

                //get parcel id
                EstablishmentParcelId = dynamicsApplication.AdoxioEstablishmentparcelid,

                //get additional property info
                AdditionalPropertyInformation = dynamicsApplication.AdoxioAdditionalpropertyinformation,
                AdoxioInvoiceId = dynamicsApplication._adoxioInvoiceValue,

                PaymentReceivedDate = dynamicsApplication.AdoxioPaymentreceiveddate,
                Description1        = dynamicsApplication.AdoxioDescription1,
                Description2        = dynamicsApplication.AdoxioDescription2,

                //get contact details
                ContactPersonFirstName = dynamicsApplication.AdoxioContactpersonfirstname,
                ContactPersonLastName  = dynamicsApplication.AdoxioContactpersonlastname,
                ContactPersonRole      = dynamicsApplication.AdoxioRole,
                ContactPersonEmail     = dynamicsApplication.AdoxioEmail,
                ContactPersonPhone     = dynamicsApplication.AdoxioContactpersonphone,

                //get record audit info
                CreatedOn  = dynamicsApplication.Createdon,
                ModifiedOn = dynamicsApplication.Modifiedon,

                //store opening
                IsReadyWorkers                  = dynamicsApplication.AdoxioIsreadyworkers,
                IsReadyNameBranding             = dynamicsApplication.AdoxioIsreadynamebranding,
                IsReadyDisplays                 = dynamicsApplication.AdoxioIsreadydisplays,
                IsReadyIntruderAlarm            = dynamicsApplication.AdoxioIsreadyintruderalarm,
                IsReadyFireAlarm                = dynamicsApplication.AdoxioIsreadyfirealarm,
                IsReadyLockedCases              = dynamicsApplication.AdoxioIsreadylockedcases,
                IsReadyLockedStorage            = dynamicsApplication.AdoxioIsreadylockedstorage,
                IsReadyPerimeter                = dynamicsApplication.AdoxioIsreadyperimeter,
                IsReadyRetailArea               = dynamicsApplication.AdoxioIsreadyretailarea,
                IsReadyStorage                  = dynamicsApplication.AdoxioIsreadystorage,
                IsReadyExtranceExit             = dynamicsApplication.AdoxioIsreadyentranceexit,
                IsReadySurveillanceNotice       = dynamicsApplication.AdoxioIsreadysurveillancenotice,
                IsReadyProductNotVisibleOutside = dynamicsApplication.AdoxioIsreadyproductnotvisibleoutside,
                IsLocatedInGroceryStore         = dynamicsApplication.AdoxioIslocatedingrocerystore,
                Establishmentopeningdate        = dynamicsApplication.AdoxioEstablishmentopeningdate,
                IsReadyValidInterest            = dynamicsApplication.AdoxioIsreadyvalidinterest,

                IsHasPatio = dynamicsApplication.AdoxioIshaspatio,

                // LgInName
                LGNameOfOfficial         = dynamicsApplication.AdoxioLgnameofofficial,
                LGTitlePosition          = dynamicsApplication.AdoxioLgtitleposition,
                LGContactPhone           = dynamicsApplication.AdoxioLgcontactphone,
                LGContactEmail           = dynamicsApplication.AdoxioLgcontactemail,
                LGDecisionSubmissionDate = dynamicsApplication.AdoxioLgdecisionsubmissiondate,
                LgInName           = dynamicsApplication?.AdoxioLocalgovindigenousnationid?.AdoxioName,
                LGApprovalDecision = (LGDecision?)dynamicsApplication.AdoxioLgapprovaldecision,
                LgZoning           = (Zoning?)dynamicsApplication.AdoxioLgzoning,
                LGDecisionComments = dynamicsApplication.AdoxioLgdecisioncomments,

                // Catering fields.

                PreviousApplicationDetails = dynamicsApplication.AdoxioPreviouslicenceapplicationdetails,

                LiquorIndustryConnectionsDetails = dynamicsApplication.AdoxioLiquorindustryconnectionsdetails,

                OtherBusinessesDetails = dynamicsApplication.AdoxioOtherbusinesssamelocationdetails,
                ServiceAreas           = new List <CapacityArea>(),
                OutsideAreas           = new List <CapacityArea>(),
                CapacityArea           = new List <CapacityArea>(),

                // Manufacturing fields

                IsPackaging = dynamicsApplication.AdoxioIspackaging,

                MfgAcresOfFruit           = dynamicsApplication.AdoxioMfgacresoffruit,
                MfgAcresOfGrapes          = dynamicsApplication.AdoxioMfgacresofgrapes,
                MfgAcresOfHoney           = dynamicsApplication.AdoxioMfgacresofhoney,
                MfgMeetsProductionMinimum = dynamicsApplication.AdoxioMfgmeetsproductionminimum,
                MfgStepBlending           = dynamicsApplication.AdoxioMfgstepblending,
                MfgStepCrushing           = dynamicsApplication.AdoxioMfgstepcrushing,
                MfgStepFiltering          = dynamicsApplication.AdoxioMfgstepfiltering,
                MfgStepSecFermOrCarb      = dynamicsApplication.AdoxioMfgstepsecfermorcarb,
                IsOwnerBusiness           = dynamicsApplication.AdoxioIsownerbusiness,
                HasValidInterest          = dynamicsApplication.AdoxioIsownerhasvalidinterest,
                WillHaveValidInterest     = dynamicsApplication.AdoxioIsownerwillhavevalidinterest,
                ZoningStatus = dynamicsApplication.AdoxioZoningstatus,


                PidList             = dynamicsApplication.AdoxioPidlist,
                IsPermittedInZoning = dynamicsApplication.AdoxioIspermittedinzoning,

                // Manufacturing structural change fields

                PatioCompDescription          = dynamicsApplication.AdoxioPatiocompdescription,
                PatioLocationDescription      = dynamicsApplication.AdoxioPatiolocationdescription,
                PatioAccessDescription        = dynamicsApplication.AdoxioPatioaccessdescription,
                PatioIsLiquorCarried          = dynamicsApplication.AdoxioPatioisliquorcarried,
                PatioLiquorCarriedDescription = dynamicsApplication.AdoxioPatioliquorcarrieddescription,
                PatioAccessControlDescription = dynamicsApplication.AdoxioPatioaccesscontroldescription,
                IsAlr           = dynamicsApplication.AdoxioProposedestablishmentisalr.HasValue && (bool)dynamicsApplication.AdoxioProposedestablishmentisalr,
                HasCoolerAccess = dynamicsApplication.AdoxioHascooleraccess.HasValue && (bool)dynamicsApplication.AdoxioHascooleraccess
            };


            // mfg fields

            if (dynamicsApplication.AdoxioMfgpipedinproduct != null)
            {
                applicationVM.MfgPipedInProduct = (YesNoNotApplicable?)dynamicsApplication.AdoxioMfgpipedinproduct;
            }
            if (dynamicsApplication.AdoxioMfgbrewpubonsite != null)
            {
                applicationVM.MfgBrewPubOnSite = (YesNoNotApplicable?)dynamicsApplication.AdoxioMfgbrewpubonsite;
            }
            if (dynamicsApplication.AdoxioMfgusesneutralgrainspirits != null)
            {
                applicationVM.MfgUsesNeutralGrainSpirits = (YesNoNotApplicable)dynamicsApplication.AdoxioMfgusesneutralgrainspirits;
            }


            if (dynamicsApplication.AdoxioLocatedabovedescription != null)
            {
                applicationVM.LocatedAboveDescription = dynamicsApplication.AdoxioLocatedabovedescription;
            }

            if (dynamicsApplication.AdoxioPatioservicebar != null)
            {
                applicationVM.PatioServiceBar = dynamicsApplication.AdoxioPatioservicebar;
            }

            // Catering yes / no fields
            if (dynamicsApplication.AdoxioPreviouslicenceapplication != null)
            {
                applicationVM.PreviousApplication = dynamicsApplication.AdoxioPreviouslicenceapplication;
            }

            if (dynamicsApplication.AdoxioRuralagencystoreappointment != null)
            {
                applicationVM.RuralAgencyStoreAppointment = dynamicsApplication.AdoxioRuralagencystoreappointment;
            }

            if (dynamicsApplication.AdoxioLiquorindustryconnections != null)
            {
                applicationVM.LiquorIndustryConnections = dynamicsApplication.AdoxioLiquorindustryconnections;
            }

            if (dynamicsApplication.AdoxioOtherbusinessesatthesamelocation != null)
            {
                applicationVM.OtherBusinesses = dynamicsApplication.AdoxioOtherbusinessesatthesamelocation;
            }


            // id
            if (dynamicsApplication.AdoxioApplicationid != null)
            {
                applicationVM.Id = dynamicsApplication.AdoxioApplicationid.ToString();

                // service areas
                var filter = $"_adoxio_applicationid_value eq {dynamicsApplication.AdoxioApplicationid}";
                try
                {
                    IList <MicrosoftDynamicsCRMadoxioServicearea> areas = dynamicsClient.Serviceareas.Get(filter: filter).Value;
                    foreach (MicrosoftDynamicsCRMadoxioServicearea area in areas)
                    {
                        if (area.AdoxioAreacategory == (int?)AdoxioAreaCategories.Service)
                        {
                            applicationVM.ServiceAreas.Add(area.ToViewModel());
                        }
                        else if (area.AdoxioAreacategory == (int?)AdoxioAreaCategories.OutdoorArea)
                        {
                            applicationVM.OutsideAreas.Add(area.ToViewModel());
                        }
                        else if (area.AdoxioAreacategory == (int?)AdoxioAreaCategories.Capacity)
                        {
                            applicationVM.CapacityArea.Add(area.ToViewModel());
                        }
                    }
                }
                catch (HttpOperationException httpOperationException)
                {
                    logger.LogError(httpOperationException, "Error getting service areas.");
                }

                // service hours
                try
                {
                    var appFilter = $"_adoxio_application_value eq {dynamicsApplication.AdoxioApplicationid}";
                    IList <MicrosoftDynamicsCRMadoxioHoursofservice> hours = dynamicsClient.Hoursofservices.Get(filter: appFilter).Value;
                    if (hours.Count > 0)
                    {
                        MicrosoftDynamicsCRMadoxioHoursofservice hourEntity = hours[0];
                        applicationVM.ServiceHoursSundayOpen     = (ServiceHours?)hourEntity.AdoxioSundayopen;
                        applicationVM.ServiceHoursSundayClose    = (ServiceHours?)hourEntity.AdoxioSundayclose;
                        applicationVM.ServiceHoursMondayOpen     = (ServiceHours?)hourEntity.AdoxioMondayopen;
                        applicationVM.ServiceHoursMondayClose    = (ServiceHours?)hourEntity.AdoxioMondayclose;
                        applicationVM.ServiceHoursTuesdayOpen    = (ServiceHours?)hourEntity.AdoxioTuesdayopen;
                        applicationVM.ServiceHoursTuesdayClose   = (ServiceHours?)hourEntity.AdoxioTuesdayclose;
                        applicationVM.ServiceHoursWednesdayOpen  = (ServiceHours?)hourEntity.AdoxioWednesdayopen;
                        applicationVM.ServiceHoursWednesdayClose = (ServiceHours?)hourEntity.AdoxioWednesdayclose;
                        applicationVM.ServiceHoursThursdayOpen   = (ServiceHours?)hourEntity.AdoxioThursdayopen;
                        applicationVM.ServiceHoursThursdayClose  = (ServiceHours?)hourEntity.AdoxioThursdayclose;
                        applicationVM.ServiceHoursFridayOpen     = (ServiceHours?)hourEntity.AdoxioFridayopen;
                        applicationVM.ServiceHoursFridayClose    = (ServiceHours?)hourEntity.AdoxioFridayclose;
                        applicationVM.ServiceHoursSaturdayOpen   = (ServiceHours?)hourEntity.AdoxioSaturdayopen;
                        applicationVM.ServiceHoursSaturdayClose  = (ServiceHours?)hourEntity.AdoxioSaturdayclose;
                    }
                }
                catch (HttpOperationException httpOperationException)
                {
                    logger.LogError(httpOperationException, "Error getting service hours.");
                }
            }

            if (dynamicsApplication.Statuscode != null)
            {
                applicationVM.ApplicationStatus = (AdoxioApplicationStatusCodes)dynamicsApplication.Statuscode;
            }

            if (dynamicsApplication.AdoxioApplicanttype != null)
            {
                applicationVM.ApplicantType = (AdoxioApplicantTypeCodes)dynamicsApplication.AdoxioApplicanttype;
            }

            //get applying person from Contact entity
            if (dynamicsApplication._adoxioApplyingpersonValue != null)
            {
                Guid applyingPersonId = Guid.Parse(dynamicsApplication._adoxioApplyingpersonValue);
                var  contact          = await dynamicsClient.GetContactById(applyingPersonId);

                applicationVM.ApplyingPerson = contact.Fullname;
            }

            if (dynamicsApplication._adoxioApplicantValue != null)
            {
                var applicant = await dynamicsClient.GetAccountByIdAsync(Guid.Parse(dynamicsApplication._adoxioApplicantValue));

                applicationVM.Applicant = applicant.ToViewModel();
            }

            //get license type from Adoxio_licencetype entity
            if (dynamicsApplication._adoxioLicencetypeValue != null)
            {
                Guid adoxio_licencetypeId = Guid.Parse(dynamicsApplication._adoxioLicencetypeValue);
                var  adoxio_licencetype   = dynamicsClient.GetAdoxioLicencetypeById(adoxio_licencetypeId);
                applicationVM.LicenseType = adoxio_licencetype.AdoxioName;
            }

            // get the license sub type.

            if (dynamicsApplication._adoxioLicencesubcategoryidValue != null)
            {
                try
                {
                    var adoxioLicencesubcategory = dynamicsClient.Licencesubcategories.GetByKey(dynamicsApplication._adoxioLicencesubcategoryidValue);
                    applicationVM.LicenceSubCategory = adoxioLicencesubcategory.AdoxioName;
                }
                catch (Exception e)
                {
                    logger.LogError(e, $"Problem getting licence sub category {dynamicsApplication._adoxioLicencesubcategoryidValue}");
                }
            }

            if (dynamicsApplication.AdoxioAppchecklistfinaldecision != null)
            {
                applicationVM.AppChecklistFinalDecision = (AdoxioFinalDecisionCodes)dynamicsApplication.AdoxioAppchecklistfinaldecision;
            }

            //get payment info
            applicationVM.InvoiceTrigger = (GeneralYesNo?)dynamicsApplication.AdoxioInvoicetrigger;
            applicationVM.IsSubmitted    = (dynamicsApplication.AdoxioInvoicetrigger == 1);


            if (dynamicsApplication.AdoxioLicenceFeeInvoice != null)
            {
                applicationVM.LicenceFeeInvoice = dynamicsApplication.AdoxioLicenceFeeInvoice.ToViewModel();
            }

            if (dynamicsApplication.AdoxioAssignedLicence != null)
            {
                applicationVM.AssignedLicence = dynamicsApplication.AdoxioAssignedLicence.ToViewModel(dynamicsClient);
            }

            if (dynamicsApplication.AdoxioApplicationTypeId != null)
            {
                applicationVM.ApplicationType = dynamicsApplication.AdoxioApplicationTypeId.ToViewModel();

                if (!string.IsNullOrEmpty(applicationVM.ApplicationType.FormReference))
                {
                    applicationVM.ApplicationType.DynamicsForm = dynamicsClient.GetSystemformViewModel(cache, logger, applicationVM.ApplicationType.FormReference);
                }
            }
            if (dynamicsApplication.AdoxioApplicationAdoxioTiedhouseconnectionApplication != null)
            {
                var tiedHouse = dynamicsApplication.AdoxioApplicationAdoxioTiedhouseconnectionApplication.FirstOrDefault();
                if (tiedHouse != null)
                {
                    applicationVM.TiedHouse = tiedHouse.ToViewModel();
                }
            }

            if (dynamicsApplication.AdoxioPoliceJurisdictionId != null)
            {
                applicationVM.PoliceJurisdiction = dynamicsApplication.AdoxioPoliceJurisdictionId.ToViewModel();
            }

            if (dynamicsApplication.AdoxioLocalgovindigenousnationid != null)
            {
                var filter        = $"_adoxio_lginlinkid_value eq {dynamicsApplication.AdoxioLocalgovindigenousnationid.AdoxioLocalgovindigenousnationid} and websiteurl ne null";
                var linkedAccount = (await dynamicsClient.Accounts.GetAsync(filter: filter)).Value.FirstOrDefault();
                applicationVM.IndigenousNation = dynamicsApplication.AdoxioLocalgovindigenousnationid.ToViewModel();

                if (linkedAccount != null)
                {
                    applicationVM.IndigenousNation.WebsiteUrl = linkedAccount.Websiteurl;
                }
            }

            applicationVM.PrevPaymentFailed = (dynamicsApplication._adoxioInvoiceValue != null) && (!applicationVM.IsSubmitted);

            return(applicationVM);
        }
예제 #2
0
 /// <summary>
 /// Update entity in adoxio_hoursofservices
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='adoxioHoursofserviceid'>
 /// key: adoxio_hoursofserviceid of adoxio_hoursofservice
 /// </param>
 /// <param name='body'>
 /// New property values
 /// </param>
 /// <param name='customHeaders'>
 /// Headers that will be added to request.
 /// </param>
 public static HttpOperationResponse UpdateWithHttpMessages(this IHoursofservices operations, string adoxioHoursofserviceid, MicrosoftDynamicsCRMadoxioHoursofservice body, Dictionary <string, List <string> > customHeaders = null)
 {
     return(operations.UpdateWithHttpMessagesAsync(adoxioHoursofserviceid, body, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult());
 }
예제 #3
0
        public string ToHtml(IDynamicsClient _dynamicsClient)
        {
            string htmlVal = "";

            // get the hours of service and create a table
            MicrosoftDynamicsCRMadoxioHoursofserviceCollection hours = _dynamicsClient.Hoursofservices.Get(filter: $"_adoxio_endorsement_value eq {EndorsementId}");

            if (hours.Value.Count > 0)
            {
                MicrosoftDynamicsCRMadoxioHoursofservice hoursVal = hours.Value.First();
                htmlVal += $@"<h3 style=""text-align: center;"">HOURS OF SALE FOR {EndorsementName.ToUpper()}</h3>
                            <table style=""width: 100%"">
                                <tr>
                                    <th></th>
                                    <th>Monday</th>
                                    <th>Tuesday</th>
                                    <th>Wednesday</th>
                                    <th>Thursday</th>
                                    <th>Friday</th>
                                    <th>Saturday</th>
                                    <th>Sunday</th>
                                </tr>
                                <tr>
                                    <td class='hours'>Start</td>
                                    <td class='hours'>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioMondayopen)}</td>
                                    <td class='hours'>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioTuesdayopen)}</td>
                                    <td class='hours'>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioWednesdayopen)}</td>
                                    <td class='hours'>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioThursdayopen)}</td>
                                    <td class='hours'>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioFridayopen)}</td>
                                    <td class='hours'>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioSaturdayopen)}</td>
                                    <td class='hours'>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioSundayopen)}</td>
                                </tr>
                                <tr>
                                    <td class='hours'>End</td>
                                    <td class='hours'>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioMondayclose)}</td>
                                    <td class='hours'>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioTuesdayclose)}</td>
                                    <td class='hours'>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioWednesdayclose)}</td>
                                    <td class='hours'>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioThursdayclose)}</td>
                                    <td class='hours'>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioFridayclose)}</td>
                                    <td class='hours'>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioSaturdayclose)}</td>
                                    <td class='hours'>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioSundayclose)}</td>
                                </tr>
                            </table>";
            }

            // get the service areas and get their html
            MicrosoftDynamicsCRMadoxioServiceareaCollection allServiceAreas = _dynamicsClient.Serviceareas.Get(filter: $"_adoxio_endorsement_value eq {EndorsementId}");

            if (allServiceAreas.Value.Count > 0)
            {
                // sort the areas
                IEnumerable <MicrosoftDynamicsCRMadoxioServicearea> serviceAreas = allServiceAreas.Value
                                                                                   .Where(area => area.AdoxioAreacategory != (int)ServiceAreaCategoryEnum.Capacity)
                                                                                   .OrderBy(area => area.AdoxioAreanumber);
                // IEnumerable<MicrosoftDynamicsCRMadoxioServicearea> outdoorAreas = allServiceAreas.Value
                //     .Where(area => area.AdoxioAreacategory == (int)ServiceAreaCategoryEnum.OutdoorEvent)
                //     .OrderBy(area => area.AdoxioAreanumber);
                IEnumerable <MicrosoftDynamicsCRMadoxioServicearea> capacityAreas = allServiceAreas.Value
                                                                                    .Where(area => area.AdoxioAreacategory == (int)ServiceAreaCategoryEnum.Capacity)
                                                                                    .OrderBy(area => area.AdoxioAreanumber);
                if (serviceAreas.Any())
                {
                    htmlVal += $@"<h3 style=""text-align: center;"">MAXIMUM CAPACITY {EndorsementName.ToUpper()}</h3>";
                }
                // print the service areas
                if (serviceAreas.Any())
                {
                    htmlVal += @"<table style='border: black 0px; padding:2px; border-collapse: separate; border-spacing: 2px;'>
                                    <tr>";

                    var cells    = 0;
                    var leftover = 0;

                    foreach (MicrosoftDynamicsCRMadoxioServicearea area in serviceAreas)
                    {
                        cells++;

                        htmlVal += $@"<td class='area'><table style='padding:0px; margin: 0px; width:100%; border: 0px solid white;'><tr><td>{area.AdoxioArealocation}{area.AdoxioAreanumber}</td><td>{area.AdoxioCapacity}</td></tr></table></td>";

                        // every 4 cells
                        leftover = cells % 4;

                        if (leftover == 0)
                        {
                            htmlVal += "</tr><tr>"; // do a new row
                        }
                    }

                    // fill in the remaining spaces
                    for (int i = 0; i < leftover; i++)
                    {
                        htmlVal += "<td class='space'>&nbsp;</td>";
                    }

                    htmlVal += "</tr></table>";
                }
            }

            return(htmlVal);
        }
예제 #4
0
 /// <summary>
 /// Update entity in adoxio_hoursofservices
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='adoxioHoursofserviceid'>
 /// key: adoxio_hoursofserviceid of adoxio_hoursofservice
 /// </param>
 /// <param name='body'>
 /// New property values
 /// </param>
 public static void Update(this IHoursofservices operations, string adoxioHoursofserviceid, MicrosoftDynamicsCRMadoxioHoursofservice body)
 {
     operations.UpdateAsync(adoxioHoursofserviceid, body).GetAwaiter().GetResult();
 }
예제 #5
0
 /// <summary>
 /// Update entity in adoxio_hoursofservices
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='adoxioHoursofserviceid'>
 /// key: adoxio_hoursofserviceid of adoxio_hoursofservice
 /// </param>
 /// <param name='body'>
 /// New property values
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task UpdateAsync(this IHoursofservices operations, string adoxioHoursofserviceid, MicrosoftDynamicsCRMadoxioHoursofservice body, CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.UpdateWithHttpMessagesAsync(adoxioHoursofserviceid, body, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
예제 #6
0
 /// <summary>
 /// Add new entity to adoxio_hoursofservices
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='body'>
 /// New entity
 /// </param>
 /// <param name='prefer'>
 /// Required in order for the service to return a JSON representation of the
 /// object.
 /// </param>
 /// <param name='customHeaders'>
 /// Headers that will be added to request.
 /// </param>
 public static HttpOperationResponse <MicrosoftDynamicsCRMadoxioHoursofservice> CreateWithHttpMessages(this IHoursofservices operations, MicrosoftDynamicsCRMadoxioHoursofservice body, string prefer = "return=representation", Dictionary <string, List <string> > customHeaders = null)
 {
     return(operations.CreateWithHttpMessagesAsync(body, prefer, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult());
 }
예제 #7
0
 /// <summary>
 /// Add new entity to adoxio_hoursofservices
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='body'>
 /// New entity
 /// </param>
 /// <param name='prefer'>
 /// Required in order for the service to return a JSON representation of the
 /// object.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <MicrosoftDynamicsCRMadoxioHoursofservice> CreateAsync(this IHoursofservices operations, MicrosoftDynamicsCRMadoxioHoursofservice body, string prefer = "return=representation", CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateWithHttpMessagesAsync(body, prefer, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
예제 #8
0
 /// <summary>
 /// Add new entity to adoxio_hoursofservices
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='body'>
 /// New entity
 /// </param>
 /// <param name='prefer'>
 /// Required in order for the service to return a JSON representation of the
 /// object.
 /// </param>
 public static MicrosoftDynamicsCRMadoxioHoursofservice Create(this IHoursofservices operations, MicrosoftDynamicsCRMadoxioHoursofservice body, string prefer = "return=representation")
 {
     return(operations.CreateAsync(body, prefer).GetAwaiter().GetResult());
 }
예제 #9
0
        /// <summary>
        /// Update entity in adoxio_hoursofservices
        /// </summary>
        /// <param name='adoxioHoursofserviceid'>
        /// key: adoxio_hoursofserviceid of adoxio_hoursofservice
        /// </param>
        /// <param name='body'>
        /// New property values
        /// </param>
        /// <param name='customHeaders'>
        /// Headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="HttpOperationException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// Thrown when a required parameter is null
        /// </exception>
        /// <return>
        /// A response object containing the response body and response headers.
        /// </return>
        public async Task <HttpOperationResponse> UpdateWithHttpMessagesAsync(string adoxioHoursofserviceid, MicrosoftDynamicsCRMadoxioHoursofservice body, Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (adoxioHoursofserviceid == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "adoxioHoursofserviceid");
            }
            if (body == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "body");
            }
            // Tracing
            bool   _shouldTrace  = ServiceClientTracing.IsEnabled;
            string _invocationId = null;

            if (_shouldTrace)
            {
                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("adoxioHoursofserviceid", adoxioHoursofserviceid);
                tracingParameters.Add("body", body);
                tracingParameters.Add("cancellationToken", cancellationToken);
                ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters);
            }
            // Construct URL
            var _baseUrl = Client.BaseUri.AbsoluteUri;
            var _url     = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "adoxio_hoursofservices({adoxio_hoursofserviceid})").ToString();

            _url = _url.Replace("{adoxio_hoursofserviceid}", System.Uri.EscapeDataString(adoxioHoursofserviceid));
            // Create HTTP transport objects
            var _httpRequest = new HttpRequestMessage();
            HttpResponseMessage _httpResponse = null;

            _httpRequest.Method     = new HttpMethod("PATCH");
            _httpRequest.RequestUri = new System.Uri(_url);
            // Set Headers


            if (customHeaders != null)
            {
                foreach (var _header in customHeaders)
                {
                    if (_httpRequest.Headers.Contains(_header.Key))
                    {
                        _httpRequest.Headers.Remove(_header.Key);
                    }
                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
                }
            }

            // Serialize Request
            string _requestContent = null;

            if (body != null)
            {
                _requestContent      = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings);
                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
                _httpRequest.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
            }
            // Set Credentials
            if (Client.Credentials != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
            }
            // Send Request
            if (_shouldTrace)
            {
                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
            }
            cancellationToken.ThrowIfCancellationRequested();
            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);

            if (_shouldTrace)
            {
                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
            }
            HttpStatusCode _statusCode = _httpResponse.StatusCode;

            cancellationToken.ThrowIfCancellationRequested();
            string _responseContent = null;

            if ((int)_statusCode != 204)
            {
                var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
                if (_httpResponse.Content != null)
                {
                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
                }
                else
                {
                    _responseContent = string.Empty;
                }
                ex.Request  = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
                if (_shouldTrace)
                {
                    ServiceClientTracing.Error(_invocationId, ex);
                }
                _httpRequest.Dispose();
                if (_httpResponse != null)
                {
                    _httpResponse.Dispose();
                }
                throw ex;
            }
            // Create Result
            var _result = new HttpOperationResponse();

            _result.Request  = _httpRequest;
            _result.Response = _httpResponse;
            if (_shouldTrace)
            {
                ServiceClientTracing.Exit(_invocationId, _result);
            }
            return(_result);
        }
예제 #10
0
        public string ToHtml(IDynamicsClient _dynamicsClient)
        {
            string htmlVal = $"<h2>{EndorsementName} Approved</h2>";

            // get the hours of service and create a table
            MicrosoftDynamicsCRMadoxioHoursofserviceCollection hours = _dynamicsClient.Hoursofservices.Get(filter: $"_adoxio_endorsement_value eq {EndorsementId}");

            if (hours.Value.Count > 0)
            {
                MicrosoftDynamicsCRMadoxioHoursofservice hoursVal = hours.Value.First();
                htmlVal += $@"<h3 style=""text-align: center;"">HOURS OF SALE FOR {EndorsementName.ToUpper()}</h3>
                            <table style=""width: 100%"">
                                <tr>
                                    <th></th>
                                    <th>Monday</th>
                                    <th>Tuesday</th>
                                    <th>Wednesday</th>
                                    <th>Thursday</th>
                                    <th>Friday</th>
                                    <th>Saturday</th>
                                    <th>Sunday</th>
                                </tr>
                                <tr>
                                    <td>Open</td>
                                    <td>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioMondayopen)}</td>
                                    <td>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioTuesdayopen)}</td>
                                    <td>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioWednesdayopen)}</td>
                                    <td>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioThursdayopen)}</td>
                                    <td>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioFridayopen)}</td>
                                    <td>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioSaturdayopen)}</td>
                                    <td>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioSundayopen)}</td>
                                </tr>
                                <tr>
                                    <td>Close</td>
                                    <td>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioMondayclose)}</td>
                                    <td>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioTuesdayclose)}</td>
                                    <td>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioWednesdayclose)}</td>
                                    <td>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioThursdayclose)}</td>
                                    <td>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioFridayclose)}</td>
                                    <td>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioSaturdayclose)}</td>
                                    <td>{StoreHoursUtility.ConvertOpenHoursToString(hoursVal.AdoxioSundayclose)}</td>
                                </tr>
                            </table>";
            }

            // get the service areas and get their html
            MicrosoftDynamicsCRMadoxioServiceareaCollection allServiceAreas = _dynamicsClient.Serviceareas.Get(filter: $"_adoxio_endorsement_value eq {EndorsementId}");

            if (allServiceAreas.Value.Count > 0)
            {
                // sort the areas
                IEnumerable <MicrosoftDynamicsCRMadoxioServicearea> serviceAreas = allServiceAreas.Value
                                                                                   .Where(area => area.AdoxioAreacategory == (int)ServiceAreaCategoryEnum.Service)
                                                                                   .OrderBy(area => area.AdoxioAreanumber);
                IEnumerable <MicrosoftDynamicsCRMadoxioServicearea> outdoorAreas = allServiceAreas.Value
                                                                                   .Where(area => area.AdoxioAreacategory == (int)ServiceAreaCategoryEnum.OutdoorEvent)
                                                                                   .OrderBy(area => area.AdoxioAreanumber);
                IEnumerable <MicrosoftDynamicsCRMadoxioServicearea> capacityAreas = allServiceAreas.Value
                                                                                    .Where(area => area.AdoxioAreacategory == (int)ServiceAreaCategoryEnum.Capacity)
                                                                                    .OrderBy(area => area.AdoxioAreanumber);
                if (serviceAreas.Any() || outdoorAreas.Any())
                {
                    htmlVal += $@"<h3 style=""text-align: center;"">MAXIMUM CAPACITY {EndorsementName.ToUpper()}</h3>";
                }
                // print the service areas
                if (serviceAreas.Any())
                {
                    htmlVal += $@"<table>
                                    <tr>
                                        <th>Area No.</th>
                                        <th>Floor Level</th>
                                        <th>Indoor</th>
                                        <th>Patio</th>
                                        <th>Occupant Load</th>
                                    </tr>";
                    foreach (MicrosoftDynamicsCRMadoxioServicearea area in serviceAreas)
                    {
                        htmlVal += $@"<tr>
                                        <td>{area.AdoxioAreanumber}</td>
                                        <td>{area.AdoxioArealocation}</td>
                                        <td>{((bool)area.AdoxioIsindoor ? "✓" : "✗")}</td>
                                        <td>{((bool)area.AdoxioIspatio ? "✓" : "✗")}</td>
                                        <td style=""font-weight: bold;"">{area.AdoxioCapacity}</td>
                                    </tr>";
                    }
                    htmlVal += "</table>";
                }

                // print the outdoor areas
                if (outdoorAreas.Any())
                {
                    htmlVal += $@"<table>
                                            <tr>
                                                <th>Area No.</th>
                                                <th>Outdoor Area</th>
                                                <th>Capacity</th>
                                            </tr>";
                    foreach (MicrosoftDynamicsCRMadoxioServicearea area in outdoorAreas)
                    {
                        htmlVal += $@"<tr>
                                        <td>{area.AdoxioAreanumber}</td>
                                        <td>{area.AdoxioArealocation}</td>
                                        <td style=""font-weight: bold;"">{area.AdoxioCapacity}</td>
                                    </tr>";
                    }
                    htmlVal += "</table>";
                }
            }

            return(htmlVal);
        }