示例#1
0
        public static object GetCurrentMFCOrNull(string valKey)
        {
            var claimsprincipal = Thread.CurrentPrincipal as ClaimsPrincipal;

            if (claimsprincipal == null)
            {
                return(null);
            }
            var claim = claimsprincipal.Claims.FirstOrDefault(c => c.Type == LibraryConst.KeyMFCs);

            if (claim == null || string.IsNullOrEmpty(claim.Value))
            {
                return(0);
            }
            List <MfcDto> vList = JsonConvert.DeserializeObject <List <MfcDto> >(claim.Value);

            if (vList != null)
            {
                MfcDto vMfc = vList.Where(p => p.Key.Equals(valKey, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
                if (vMfc != null)
                {
                    return(vMfc.Value);
                }
            }
            return(null);
        }
示例#2
0
 private static void ActualizarListaMfc(string valKey, object valvalue, List <MfcDto> vList)
 {
     if (vList.Count(p => p.Key.Equals(valKey, StringComparison.CurrentCultureIgnoreCase)) > 0)
     {
         MfcDto vMfc = vList.Where(p => p.Key.Equals(valKey, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
         vMfc.Value = valvalue;
     }
     else
     {
         vList.Add(new MfcDto()
         {
             Key = valKey, Value = valvalue
         });
     }
 }