public bool isCorporateDetailsComplete(AdoxioApplicantTypeCodes?legalentitytype, bool corporateDetailsFilesExists) { var isComplete = false; var tiedHouse = new ViewModels.TiedHouseConnection(); switch (legalentitytype) { case AdoxioApplicantTypeCodes.PrivateCorporation: case AdoxioApplicantTypeCodes.PublicCorporation: case AdoxioApplicantTypeCodes.UnlimitedLiabilityCorporation: case AdoxioApplicantTypeCodes.LimitedLiabilityCorporation: case AdoxioApplicantTypeCodes.Society: isComplete = !string.IsNullOrEmpty(bcIncorporationNumber) && !string.IsNullOrEmpty(businessNumber) && (dateOfIncorporationInBC != null) && !string.IsNullOrEmpty(contactEmail) && !string.IsNullOrEmpty(contactPhone) && !string.IsNullOrEmpty(mailingAddressName) && !string.IsNullOrEmpty(mailingAddressStreet) && !string.IsNullOrEmpty(mailingAddressCity) && !string.IsNullOrEmpty(mailingAddressCountry) && (mailingAddressProvince != null) &&// TODO: This field should be a string(by Moffat) !string.IsNullOrEmpty(mailingAddressPostalCode) && corporateDetailsFilesExists; break; case AdoxioApplicantTypeCodes.SoleProprietor: isComplete = !string.IsNullOrEmpty(businessNumber) && !string.IsNullOrEmpty(contactEmail) && !string.IsNullOrEmpty(contactPhone) && !string.IsNullOrEmpty(mailingAddressName) && !string.IsNullOrEmpty(mailingAddressStreet) && !string.IsNullOrEmpty(mailingAddressCity) && !string.IsNullOrEmpty(mailingAddressCountry) && (mailingAddressProvince != null) && !string.IsNullOrEmpty(mailingAddressPostalCode); break; case AdoxioApplicantTypeCodes.GeneralPartnership: case AdoxioApplicantTypeCodes.LimitedLiabilityPartnership: case AdoxioApplicantTypeCodes.LimitedPartnership: isComplete = !string.IsNullOrEmpty(businessNumber) && !string.IsNullOrEmpty(contactEmail) && !string.IsNullOrEmpty(contactPhone) && !string.IsNullOrEmpty(mailingAddressName) && !string.IsNullOrEmpty(mailingAddressStreet) && !string.IsNullOrEmpty(mailingAddressCity) && !string.IsNullOrEmpty(mailingAddressCountry) && (mailingAddressProvince != null) && !string.IsNullOrEmpty(mailingAddressPostalCode) && corporateDetailsFilesExists; break; default: isComplete = false; break; } return(isComplete); }
/// <summary> /// Convert a Dynamics Legal Entity to a ViewModel /// </summary> public static ViewModels.TiedHouseConnection ToViewModel(this MicrosoftDynamicsCRMadoxioTiedhouseconnection tiedHouse) { ViewModels.TiedHouseConnection result = null; if (tiedHouse != null) { result = new ViewModels.TiedHouseConnection(); if (tiedHouse.AdoxioTiedhouseconnectionid != null) { result.id = tiedHouse.AdoxioTiedhouseconnectionid.ToString(); } result.CorpConnectionFederalProducer = tiedHouse.AdoxioCorpconnectionfederalproducer; result.CorpConnectionFederalProducerDetails = tiedHouse.AdoxioCorpconnectionfederalproducerdetails; result.FamilyMemberFederalProducer = tiedHouse.AdoxioFamilymemberfederalproducer; result.FamilyMemberFederalProducerDetails = tiedHouse.AdoxioFamilymemberfederalproducerdetails; result.FederalProducerConnectionToCorp = tiedHouse.AdoxioFederalproducerconnectiontocorp; result.FederalProducerConnectionToCorpDetails = tiedHouse.AdoxioFederalproducerconnectiontocorpdetails; result.IsConnection = tiedHouse.AdoxioIsconnection; result.PartnersConnectionFederalProducer = tiedHouse.AdoxioPartnersconnectionfederalproducer; result.PartnersConnectionFederalProducerDetails = tiedHouse.AdoxioPartnersconnectionfederalproducerdetails; result.PercentageofOwnership = tiedHouse.AdoxioPercentageofownership; result.Share20PlusConnectionProducer = tiedHouse.AdoxioShare20plusconnectionproducer; result.Share20PlusConnectionProducerDetails = tiedHouse.AdoxioShare20plusconnectionproducerdetails; result.Share20PlusFamilyConnectionProducer = tiedHouse.AdoxioShare20plusfamilyconnectionproducer; result.Share20PlusFamilyConnectionProducerDetail = tiedHouse.AdoxioShare20plusfamilyconnectionproducerdetail; result.ShareType = tiedHouse.AdoxioSharetype; result.SocietyConnectionFederalProducer = tiedHouse.AdoxioSocietyconnectionfederalproducer; result.SocietyConnectionFederalProducerDetails = tiedHouse.AdoxioSocietyconnectionfederalproducerdetails; } return(result); }
public ActionResult AddTiedHouseConnection([FromBody] ViewModels.TiedHouseConnection item, string accountId) { if (item == null) { return(BadRequest()); } var tiedHouse = new MicrosoftDynamicsCRMadoxioTiedhouseconnection(); // copy values over from the data provided tiedHouse.CopyValues(item); tiedHouse.AccountODataBind = _dynamicsClient.GetEntityURI("accounts", accountId); try { tiedHouse = _dynamicsClient.Tiedhouseconnections.Create(tiedHouse); } catch (HttpOperationException httpOperationException) { tiedHouse.AdoxioTiedhouseconnectionid = _dynamicsClient.GetCreatedRecord(httpOperationException, null); if (string.IsNullOrEmpty(tiedHouse.AdoxioTiedhouseconnectionid)) { _logger.LogError(httpOperationException, "Error creating tiedhouse connection "); throw new Exception("Error creating tiedhouse connection"); } } catch (Exception e) { _logger.LogError(e, "Error creating tiedhouse connection"); throw new Exception("Error creating tiedhouse connection"); } return(new JsonResult(tiedHouse.ToViewModel())); }
public ActionResult AddTiedHouseConnection([FromBody] ViewModels.TiedHouseConnection item, string accountId) { if (item == null) { return(BadRequest()); } var tiedHouse = new MicrosoftDynamicsCRMadoxioTiedhouseconnection(); // copy values over from the data provided tiedHouse.CopyValues(item); tiedHouse.AccountODataBind = _dynamicsClient.GetEntityURI("accounts", accountId); try { tiedHouse = _dynamicsClient.Tiedhouseconnections.Create(tiedHouse); } catch (OdataerrorException odee) { tiedHouse.AdoxioTiedhouseconnectionid = _dynamicsClient.GetCreatedRecord(odee, null); if (string.IsNullOrEmpty(tiedHouse.AdoxioTiedhouseconnectionid)) { _logger.LogError("Error creating tiedhouse connection"); _logger.LogError("Request:"); _logger.LogError(odee.Request.Content); _logger.LogError("Response:"); _logger.LogError(odee.Response.Content); throw new Exception("Unable to update tied house connections"); } } return(Json(tiedHouse.ToViewModel())); }
/// <summary> /// Convert a Dynamics Legal Entity to a ViewModel /// </summary> public static ViewModels.TiedHouseConnection ToViewModel(this MicrosoftDynamicsCRMadoxioTiedhouseconnection tiedHouse) { ViewModels.TiedHouseConnection result = null; if (tiedHouse != null) { result = new ViewModels.TiedHouseConnection(); if (tiedHouse.AdoxioTiedhouseconnectionid != null) { result.id = tiedHouse.AdoxioTiedhouseconnectionid.ToString(); } result.CorpConnectionFederalProducer = tiedHouse.AdoxioCorpconnectionfederalproducer; result.CorpConnectionFederalProducerDetails = tiedHouse.AdoxioCorpconnectionfederalproducerdetails; result.FamilyMemberFederalProducer = tiedHouse.AdoxioFamilymemberfederalproducer; result.FamilyMemberFederalProducerDetails = tiedHouse.AdoxioFamilymemberfederalproducerdetails; result.FederalProducerConnectionToCorp = tiedHouse.AdoxioFederalproducerconnectiontocorp; result.FederalProducerConnectionToCorpDetails = tiedHouse.AdoxioFederalproducerconnectiontocorpdetails; result.IsConnection = tiedHouse.AdoxioIsconnection; result.PartnersConnectionFederalProducer = tiedHouse.AdoxioPartnersconnectionfederalproducer; result.PartnersConnectionFederalProducerDetails = tiedHouse.AdoxioPartnersconnectionfederalproducerdetails; result.PercentageofOwnership = tiedHouse.AdoxioPercentageofownership; result.Share20PlusConnectionProducer = tiedHouse.AdoxioShare20plusconnectionproducer; result.Share20PlusConnectionProducerDetails = tiedHouse.AdoxioShare20plusconnectionproducerdetails; result.Share20PlusFamilyConnectionProducer = tiedHouse.AdoxioShare20plusfamilyconnectionproducer; result.Share20PlusFamilyConnectionProducerDetail = tiedHouse.AdoxioShare20plusfamilyconnectionproducerdetail; result.ShareType = tiedHouse.AdoxioSharetype; result.SocietyConnectionFederalProducer = tiedHouse.AdoxioSocietyconnectionfederalproducer; result.SocietyConnectionFederalProducerDetails = tiedHouse.AdoxioSocietyconnectionfederalproducerdetails; result.LiquorFinancialInterest = tiedHouse.AdoxioLiquorfinancialinterest; result.LiquorFinancialInterestDetails = tiedHouse.AdoxioLiquorfinancialinterestdetails; result.ConnectionType = (TiedHouseConnectionType?)tiedHouse.AdoxioConnectiontype; result.CrsConnectionToMarketer = (MarketerYesNo?)tiedHouse.AdoxioCrsconnectiontomarketer; result.CrsConnectionToMarketerDetails = tiedHouse.AdoxioCrsconnectiontomarketerdetails; result.MarketerConnectionToCrs = (MarketerYesNo?)tiedHouse.AdoxioMarketerconnectiontocrs; result.MarketerConnectionToCrsDetails = tiedHouse.AdoxioMarketerconnectiontocrsdetails; result.INConnectionToFederalProducer = (MarketerYesNo?)tiedHouse.AdoxioInconnectiontofederalproducer; result.INConnectionToFederalProducerDetails = tiedHouse.AdoxioInconnectiontofederalproducerdetails; } return(result); }
public async Task <IActionResult> UpdateTiedHouse([FromBody] ViewModels.TiedHouseConnection item, string id) { if (item == null || id != item.id) { return(BadRequest()); } // get the legal entity. Guid tiedHouseId = new Guid(id); MicrosoftDynamicsCRMadoxioTiedhouseconnection res = await _dynamicsClient.GetTiedHouseConnectionById(tiedHouseId); if (res == null) { return(new NotFoundResult()); } // we are doing a patch, so wipe out the record. var tiedHouse = new MicrosoftDynamicsCRMadoxioTiedhouseconnection(); // copy values over from the data provided tiedHouse.CopyValues(item); try { await _dynamicsClient.AdoxioTiedhouseconnections.UpdateAsync(tiedHouseId.ToString(), tiedHouse); } catch (OdataerrorException odee) { _logger.LogError("Error updating tied house connections"); _logger.LogError("Request:"); _logger.LogError(odee.Request.Content); _logger.LogError("Response:"); _logger.LogError(odee.Response.Content); throw new Exception("Unable to update tied house connections"); } return(Json(tiedHouse.ToViewModel())); }
/// <summary> /// Copy values from a Dynamics legal entity to another one /// </summary> /// <param name="to"></param> /// <param name="from"></param> public static void CopyValues(this MicrosoftDynamicsCRMadoxioTiedhouseconnection to, ViewModels.TiedHouseConnection from) { to.AdoxioTiedhouseconnectionid = from.id; to.AdoxioCorpconnectionfederalproducer = from.CorpConnectionFederalProducer; to.AdoxioCorpconnectionfederalproducerdetails = from.CorpConnectionFederalProducerDetails; to.AdoxioFamilymemberfederalproducer = from.FamilyMemberFederalProducer; to.AdoxioFamilymemberfederalproducerdetails = from.FamilyMemberFederalProducerDetails; to.AdoxioFederalproducerconnectiontocorp = from.FederalProducerConnectionToCorp; to.AdoxioFederalproducerconnectiontocorpdetails = from.FederalProducerConnectionToCorpDetails; to.AdoxioIsconnection = from.IsConnection; to.AdoxioPartnersconnectionfederalproducer = from.PartnersConnectionFederalProducer; to.AdoxioPartnersconnectionfederalproducerdetails = from.PartnersConnectionFederalProducerDetails; to.AdoxioPercentageofownership = from.PercentageofOwnership; to.AdoxioShare20plusconnectionproducer = from.Share20PlusConnectionProducer; to.AdoxioShare20plusconnectionproducerdetails = from.Share20PlusConnectionProducerDetails; to.AdoxioShare20plusfamilyconnectionproducer = from.Share20PlusFamilyConnectionProducer; to.AdoxioShare20plusfamilyconnectionproducerdetail = from.Share20PlusFamilyConnectionProducerDetail; to.AdoxioSharetype = from.ShareType; to.AdoxioSocietyconnectionfederalproducer = from.SocietyConnectionFederalProducer; to.AdoxioSocietyconnectionfederalproducerdetails = from.SocietyConnectionFederalProducerDetails; }
/// <summary> /// Copy values from a Dynamics legal entity to another one /// </summary> /// <param name="to"></param> /// <param name="from"></param> public static void CopyValues(this MicrosoftDynamicsCRMadoxioTiedhouseconnection to, ViewModels.TiedHouseConnection from) { to.AdoxioTiedhouseconnectionid = from.id; to.AdoxioCorpconnectionfederalproducer = from.CorpConnectionFederalProducer; to.AdoxioCorpconnectionfederalproducerdetails = from.CorpConnectionFederalProducerDetails; to.AdoxioFamilymemberfederalproducer = from.FamilyMemberFederalProducer; to.AdoxioFamilymemberfederalproducerdetails = from.FamilyMemberFederalProducerDetails; to.AdoxioFederalproducerconnectiontocorp = from.FederalProducerConnectionToCorp; to.AdoxioFederalproducerconnectiontocorpdetails = from.FederalProducerConnectionToCorpDetails; to.AdoxioIsconnection = from.IsConnection; to.AdoxioPartnersconnectionfederalproducer = from.PartnersConnectionFederalProducer; to.AdoxioPartnersconnectionfederalproducerdetails = from.PartnersConnectionFederalProducerDetails; to.AdoxioPercentageofownership = from.PercentageofOwnership; to.AdoxioShare20plusconnectionproducer = from.Share20PlusConnectionProducer; to.AdoxioShare20plusconnectionproducerdetails = from.Share20PlusConnectionProducerDetails; to.AdoxioShare20plusfamilyconnectionproducer = from.Share20PlusFamilyConnectionProducer; to.AdoxioShare20plusfamilyconnectionproducerdetail = from.Share20PlusFamilyConnectionProducerDetail; to.AdoxioSharetype = from.ShareType; to.AdoxioSocietyconnectionfederalproducer = from.SocietyConnectionFederalProducer; to.AdoxioSocietyconnectionfederalproducerdetails = from.SocietyConnectionFederalProducerDetails; to.AdoxioSocietyconnectionfederalproducer = from.SocietyConnectionFederalProducer; to.AdoxioSocietyconnectionfederalproducerdetails = from.SocietyConnectionFederalProducerDetails; to.AdoxioConnectiontype = (int?)from.ConnectionType; to.AdoxioCrsconnectiontomarketer = (int?)from.CrsConnectionToMarketer; to.AdoxioCrsconnectiontomarketerdetails = from.CrsConnectionToMarketerDetails; to.AdoxioMarketerconnectiontocrs = (int?)from.MarketerConnectionToCrs; to.AdoxioMarketerconnectiontocrsdetails = from.MarketerConnectionToCrsDetails; to.AdoxioInconnectiontofederalproducer = (int?)from.INConnectionToFederalProducer; to.AdoxioInconnectiontofederalproducerdetails = from.INConnectionToFederalProducerDetails; to.AdoxioLiquorfinancialinterest = (int?)from.LiquorFinancialInterest; to.AdoxioLiquorfinancialinterestdetails = from.LiquorFinancialInterestDetails; }