Example #1
0
 public static void AddLocals(ContentURI uri, int defaultAddId,
                              XElement selectedElement)
 {
     //if the selected element has xmldocs, don't interfere with them
     if (!selectedElement.HasElements)
     {
         bool bNeedsLocals = NeedsLocals(selectedElement, defaultAddId);
         if (bNeedsLocals)
         {
             if (uri.URIMember.ClubInUse.AccountToLocal != null)
             {
                 AccountToLocal defaultLocal = GetIsDefaultLocal(uri);
                 if (defaultLocal != null)
                 {
                     //these assist the ui for newly inserted economics nodes
                     //i.e. by giving them the right units of measurement in the drop down selections
                     selectedElement.SetAttributeValue(
                         UNITGROUP_ID, defaultLocal.UnitGroupId.ToString());
                     selectedElement.SetAttributeValue(
                         CURRENCYGROUP_ID, defaultLocal.CurrencyGroupId.ToString());
                     selectedElement.SetAttributeValue(
                         REAL_RATE_ID, defaultLocal.RealRateId.ToString());
                     selectedElement.SetAttributeValue(
                         NOMINAL_RATE_ID, defaultLocal.NominalRateId.ToString());
                     selectedElement.SetAttributeValue(
                         RATINGGROUP_ID, defaultLocal.RatingGroupId.ToString());
                 }
             }
         }
     }
 }
Example #2
0
        public static AccountToLocal GetIsDefaultLocal(ContentURI uri)
        {
            AccountToLocal defaultLocal = null;

            if (uri.URIMember.ClubInUse.AccountToLocal != null)
            {
                defaultLocal = uri.URIMember.ClubInUse.AccountToLocal.FirstOrDefault(
                    l => l.IsDefaultLinkedView == true);
            }
            return(defaultLocal);
        }
Example #3
0
        public static async Task <AccountToLocal> GetDefaultLocal(ContentURI uri,
                                                                  DataAccess.DevTreksContext context)
        {
            AccountToLocal local = null;

            if (uri.URIMember != null && context != null)
            {
                local = await context.AccountToLocal
                        .Where(cl => cl.AccountId == uri.URIMember.AccountId &&
                               cl.IsDefaultLinkedView == true)
                        .FirstOrDefaultAsync();
            }
            return(local);
        }
Example #4
0
        public async Task <List <AccountToLocal> > GetLocalsByClubIdAsync(
            ContentURI uri, int accountId)
        {
            List <AccountToLocal> colClubLocals = new List <AccountToLocal>();

            if (accountId == 0)
            {
                //set default objects
                AccountToLocal atol = new AccountToLocal(true);
                colClubLocals.Add(atol);
                return(colClubLocals);
            }
            Helpers.SqlIOAsync sqlIO    = new Helpers.SqlIOAsync(uri);
            SqlParameter[]     colPrams =
            {
                sqlIO.MakeInParam("@AccountId", SqlDbType.Int, 4, accountId)
            };
            SqlDataReader dataReader = await sqlIO.RunProcAsync(
                "0GetLocalsByClubId", colPrams);

            if (dataReader != null)
            {
                using (dataReader)
                {
                    while (await dataReader.ReadAsync())
                    {
                        AccountToLocal atol = new AccountToLocal(true);
                        atol.PKId                = dataReader.GetInt32(0);
                        atol.LocalName           = dataReader.GetString(1);
                        atol.LocalDesc           = dataReader.GetString(2);
                        atol.UnitGroupId         = dataReader.GetInt32(3);
                        atol.UnitGroup           = dataReader.GetString(4);
                        atol.CurrencyGroupId     = dataReader.GetInt32(5);
                        atol.CurrencyGroup       = dataReader.GetString(6);
                        atol.RealRateId          = dataReader.GetInt32(7);
                        atol.RealRate            = dataReader.GetFloat(8);
                        atol.NominalRateId       = dataReader.GetInt32(9);
                        atol.NominalRate         = dataReader.GetFloat(10);
                        atol.DataSourceTechId    = dataReader.GetInt32(11);
                        atol.DataSourceTech      = dataReader.GetString(12);
                        atol.GeoCodeTechId       = dataReader.GetInt32(13);
                        atol.GeoCodeTech         = dataReader.GetString(14);
                        atol.DataSourcePriceId   = dataReader.GetInt32(15);
                        atol.DataSourcePrice     = dataReader.GetString(16);
                        atol.GeoCodePriceId      = dataReader.GetInt32(17);
                        atol.GeoCodePrice        = dataReader.GetString(18);
                        atol.RatingGroupId       = dataReader.GetInt32(19);
                        atol.RatingGroup         = dataReader.GetString(20);
                        atol.AccountId           = dataReader.GetInt32(21);
                        atol.IsDefaultLinkedView = dataReader.GetBoolean(22);
                        atol.Account             = new Account();
                        //2.0.0 deprecated
                        //atol.LinkedViewId = dataReader.GetInt32(22);
                        //atol.LinkingXmlDoc = atol.LinkedViewName;
                        //atol.LinkedView = new LinkedView();
                        colClubLocals.Add(atol);
                    }
                }
            }
            else
            {
                //set default objects
                AccountToLocal aton = new AccountToLocal(true);
                colClubLocals.Add(aton);
            }
            sqlIO.Dispose();
            return(colClubLocals);
        }
Example #5
0
        private bool AddLocals(List <ContentURI> addedURIs, List <AccountToLocal> addedMs)
        {
            bool   bHasSet         = true;
            string sParentNodeName = string.Empty;
            int    iParentId       = 0;

            foreach (ContentURI addedURI in addedURIs)
            {
                //not essential with a 2 level hierarchy, but keep the pattern consistent
                Helpers.GeneralHelpers.GetParentIdAndNodeName(addedURI, out iParentId, out sParentNodeName);
                if (!string.IsNullOrEmpty(addedURI.ErrorMessage))
                {
                    _dtoContentURI.ErrorMessage = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg(
                        string.Empty, "INSERT_NOPARENT");
                    return(false);
                }
                //2.0.0 -direct edits allowed for newly added default locals
                if (addedURI.URINodeName == Locals.LOCAL_TYPES.local.ToString() &&
                    _dtoContentURI.URINodeName == Locals.LOCAL_TYPES.localaccountgroup.ToString())
                {
                    var newAccountToLocal = new AccountToLocal
                    {
                        LocalName           = addedURI.URIName,
                        LocalDesc           = Helpers.GeneralHelpers.NONE,
                        UnitGroupId         = 0,
                        UnitGroup           = string.Empty,
                        CurrencyGroupId     = 0,
                        CurrencyGroup       = string.Empty,
                        RealRateId          = 0,
                        RealRate            = 0,
                        NominalRateId       = 0,
                        NominalRate         = 0,
                        DataSourceTechId    = 0,
                        DataSourceTech      = string.Empty,
                        GeoCodeTechId       = 0,
                        GeoCodeTech         = string.Empty,
                        DataSourcePriceId   = 0,
                        DataSourcePrice     = string.Empty,
                        GeoCodePriceId      = 0,
                        GeoCodePrice        = string.Empty,
                        RatingGroupId       = 0,
                        RatingGroup         = string.Empty,
                        IsDefaultLinkedView = false,
                        //parentid is the same as dtoURI
                        AccountId = _dtoContentURI.URIId,
                        Account   = null,
                    };
                    _dataContext.AccountToLocal.Add(newAccountToLocal);
                    _dataContext.Entry(newAccountToLocal).State = EntityState.Added;
                    addedMs.Add(newAccountToLocal);
                }
                else if (addedURI.URINodeName == LinkedViews.LINKEDVIEWS_TYPES.linkedview.ToString() &&
                         _dtoContentURI.URINodeName == Locals.LOCAL_TYPES.localaccountgroup.ToString())
                {
                    //2.0.0 deprecated local linked view calculators,
                    //retain for potential uses
                    //var newAccountToLocal = new AccountToLocal
                    //{
                    //    LocalName = addedURI.URIName,
                    //    LocalDesc = Helpers.GeneralHelpers.NONE,
                    //    UnitGroupId = 0,
                    //    UnitGroup = string.Empty,
                    //    CurrencyGroupId = 0,
                    //    CurrencyGroup = string.Empty,
                    //    RealRateId = 0,
                    //    RealRate = 0,
                    //    NominalRateId = 0,
                    //    NominalRate = 0,
                    //    DataSourceTechId = 0,
                    //    DataSourceTech = string.Empty,
                    //    GeoCodeTechId = 0,
                    //    GeoCodeTech = string.Empty,
                    //    DataSourcePriceId = 0,
                    //    DataSourcePrice = string.Empty,
                    //    GeoCodePriceId = 0,
                    //    GeoCodePrice = string.Empty,
                    //    RatingGroupId = 0,
                    //    RatingGroup = string.Empty,
                    //    IsDefaultLinkedView = false,
                    //    LinkingXmlDoc = string.Empty,
                    //    AccountId = _dtoContentURI.URIId,
                    //    Account = null,
                    //    LinkedViewId = addedURI.URIId,
                    //    //LinkedView = null
                    //};
                    //_dataContext.AccountToLocal.Add(newAccountToLocal);
                    //_dataContext.Entry(newAccountToLocal).State = EntityState.Added;
                    //addedMs.Add(newAccountToLocal);
                }
            }
            return(bHasSet);
        }