AIMS_BD_IATI.DAL.AimsDAL.GetFundSources C# (CSharp) Method

GetFundSources() public method

public GetFundSources ( string userId ) : List
userId string
return List
        public List<DPLookupItem> GetFundSources(string userId)
        {
            var FundSource = new List<DPLookupItem>();

            var userInfo = dbContext.tblUserRegistrationInfoes.FirstOrDefault(f => f.UserId == userId);

            if (userInfo != null && userInfo.UserId != "guest")
            {
                if (userInfo.ProjectPermissionType == 0) //0 = All
                {
                    FundSource = (from fundSource in dbContext.tblFundSources
                                  where fundSource.IATICode != null && !string.IsNullOrEmpty(fundSource.IATICode)
                                  orderby fundSource.FundSourceName
                                  select new DPLookupItem
                                  {
                                      ID = fundSource.IATICode,
                                      Name = fundSource.FundSourceName + " (" + (fundSource.Acronym ?? "") + ")",
                                      AimsFundSourceId = fundSource.Id,
                                      FundSourceCategoryId = fundSource.FundSourceCategoryId
                                  }).ToList();
                }
                else
                {
                    if (userInfo.ProjectPermissionType == 1) //1= Projectwise
                    {
                        FundSource = null;
                    }
                    else if (userInfo.ProjectPermissionType == 2)
                    {
                        FundSource = (from fundSource in dbContext.tblFundSources
                                      join permitted in dbContext.tblUserFundSources.Where(permitted => permitted.UserId == userInfo.Id) on fundSource.Id equals permitted.FundSourceId
                                      where fundSource.IATICode != null && !string.IsNullOrEmpty(fundSource.IATICode)
                                      orderby fundSource.FundSourceName
                                      select new DPLookupItem
                                      {
                                          ID = fundSource.IATICode,
                                          Name = fundSource.FundSourceName + " (" + (fundSource.Acronym ?? "") + ")",
                                          AimsFundSourceId = fundSource.Id,
                                          FundSourceCategoryId = fundSource.FundSourceCategoryId
                                      }).ToList();

                    }
                }
            }
            return FundSource;
        }

Same methods

AimsDAL::GetFundSources ( ) : List

Usage Example

Example #1
0
        /// <summary>
        /// Parse IATI XML data from IATI data store and converts from v1 to v2
        /// </summary>
        /// <returns></returns>
        private static void ParseIATI()
        {

            //Get list of FundSource from AIMS DB
            AimsDAL _AimsDAL = new AimsDAL();
            var fundSources = _AimsDAL.GetFundSources();//.FindAll(q => q.IATICode == "SE-0");

            int i = 1;
            foreach (var fundSource in fundSources)
            {

                Thread th = new Thread(new ThreadStart(() =>
                {
                    Parser p = new Parser();
                    p.Parse(fundSources.Count, i++, fundSource);
                    p = null;
                }));
                th.Start();

                th.Join();
            }
        }