示例#1
0
        public Identity(IIdentity identity)
        {
            if (identity == null)
            {
                throw new ArgumentNullException("identity");
            }

            ClrType = identity.GetType().FullName;

            if (!identity.IsAuthenticated)
            {
                IsAuthenticated = false;
                return;
            }

            Name = identity.Name;
            AuthenticationType = identity.AuthenticationType;
            IsAuthenticated = true;

            var claimsIdentity = identity as ClaimsIdentity;
            if (claimsIdentity != null)
            {
                Claims = new Claims();
                claimsIdentity.Claims.ToList().ForEach(c => Claims.Add(new Claim
                            {
                                ClaimType = c.ClaimType,
                                Value = c.Value,
                                Issuer = c.Issuer,
                                OriginalIssuer = c.OriginalIssuer
                            }));
            }
        }
示例#2
0
 public void AddClaim(Claim claim)
 {
     Claims.Add(claim);
 }
示例#3
0
 public virtual void AddClaim([NotNull] string value, string type)
 {
     Claims.Add(new ClientClaim(Id, type, value));
 }
示例#4
0
 internal void AddClaim(Claim claim)
 {
     Claims.Add(claim);
 }
示例#5
0
        public void AddClaim(string claimType, string claimValue)
        {
            var claim = new Claim(this.Id, claimType, claimValue);

            Claims.Add(claim);
        }
        async public void submitClaim(object o)
        {
            #region Process Lead

            // Create needed KnockerResponse or Referrer if needed.
            if (Lead.LeadTypeID == 1) // Knocker
            {
                // If KnockerResponse does not exist

                if (KnockerResponse.KnockerResponseID == 0)
                {
                    if ((ErrorMessage = await new ServiceLayer().AddKnockerResponse(KnockerResponse.toDTO())) != null)
                    {
                        return;
                    }
                }
                else
                {
                    if ((ErrorMessage = await new ServiceLayer().UpdateKnockerResponse(KnockerResponse.toDTO())) != null)
                    {
                        return;
                    }
                }

                KnockerResponse        = new KnockerResponse(ServiceLayer.KnockerResponse);
                Lead.KnockerResponseID = KnockerResponse.KnockerResponseID;
                Lead.CreditToID        = KnockerResponse.KnockerID;
                //Lead.CreditTo = Employee.FirstName + " " + Employee.LastName;
            }
            else if (Lead.LeadTypeID == 2) // Referrer
            {
                if (Referrer.ReferrerID == 0)
                {
                    if ((ErrorMessage = await new ServiceLayer().AddReferrer(Referrer.toDTO())) != null)
                    {
                        return;
                    }
                }
                else
                {
                    if ((ErrorMessage = await new ServiceLayer().UpdateReferrer(Referrer.toDTO())) != null)
                    {
                        return;
                    }
                }

                Referrer        = new Referrer(ServiceLayer.Referrer);
                Lead.CreditToID = Referrer.ReferrerID;
                Lead.CreditTo   = Referrer.FirstName + " " + Referrer.LastName;
            }

            Lead.SalespersonID = LoggedInEmployee.EmployeeID;
            Lead.CustomerID    = Customer.CustomerID;
            Lead.AddressID     = PropertyAddress.AddressID;
            Lead.Status        = "A";

            if (Lead.LeadID == 0)
            {
                if ((ErrorMessage = await new ServiceLayer().AddLead(Lead.toDTO())) != null)
                {
                    return;
                }

                Lead.LeadID = ServiceLayer.Lead.LeadID;
            }
            else
            {
                if ((ErrorMessage = await new ServiceLayer().UpdateLead(Lead.toDTO())) != null)
                {
                    return;
                }
            }

            #endregion

            #region Claim
            if (Claim.ClaimID == 0) // If the Claim doesn't exist (it should exist)
            {
                // Create the Claim
                if ((ErrorMessage = await new ServiceLayer().AddClaim(Claim.toDTO())) != null)
                {
                    return;
                }

                // Add it to the Claims list
                Claims.Add(new Claim(ServiceLayer.Claim));
            }
            else if (Claim.ClaimID > 0) // If the Claim does exist (it should)
            {
                // Update the Claim
                if ((ErrorMessage = await new ServiceLayer().UpdateClaim(Claim.toDTO())) != null)
                {
                    return;
                }

                // Overwrite the original Claim in the Claims list with the updated information
                Claim claim = Claims.Where(c => c.ClaimID == Claim.ClaimID).Single();
                int   index = Claims.IndexOf(claim);
                Claims[index] = new Claim(ServiceLayer.Claim);
                Customer      = Customers.Where(c => c.CustomerID == Claim.CustomerID).Single();
                Claims[index].CustomerName = Customer.FirstName + " " + Customer.LastName;
                Claims[index].Address      = Addresses.Where(a => a.AddressID == Claims[index].PropertyID).Single().FullAddress;
            }
            #endregion
        }
 public virtual void AddClaim(Claim claim)
 {
     Claims.Add(new IdentityUserClaim(claim));
 }
示例#8
0
 public void AddClaim(string claimType, string value)
 {
     Claims.Add(new KeyValuePair <string, string>(claimType, value));
 }
示例#9
0
 public virtual void AddClaim(IGuidGenerator guidGenerator, [NotNull] string type, string value)
 {
     Claims.Add(new ClientClaim(guidGenerator.Create(), Id, type, value));
 }
示例#10
0
        public void AddClaim(string claimType, string claimValue)
        {
            Claims.Add(new Claim(claimType, claimValue));

            InitializeReturnValue();
        }
示例#11
0
 public ManagerClaimListVM()
 {
     PeriodMgtAppLocalizedResources = new PeriodMgtAppLocalizedResources();
     init();
     Claims.Add(new ClaimDTOWithAction());
 }
        /// <summary>
        /// Creates a new <see cref="ModelController{T}"/>
        /// </summary>
        public ModelController()
        {
            PrimaryKeyField = typeof(T).GetProperties().FirstOrDefault(p => p.GetCustomAttributes <PrimaryKeyAttribute>().Any())?.Name ?? "ID";

            ParentKey  = typeof(T).GetProperties().FirstOrDefault(p => p.GetCustomAttributes <ParentKeyAttribute>().Any())?.Name ?? "";
            Connection = typeof(T).GetCustomAttribute <SettingsCategoryAttribute>()?.SettingsCategory ?? "systemSettings";

            PropertyInfo pi = typeof(T).GetProperties().FirstOrDefault(p => p.GetCustomAttributes <DefaultSortOrderAttribute>().Any());
            DefaultSortOrderAttribute dsoa = pi?.GetCustomAttribute <DefaultSortOrderAttribute>();

            if (dsoa != null)
            {
                DefaultSort = $"{pi.Name} {(dsoa.Ascending ? "ASC" : "DESC")}";
            }

            if (User.GetType() == typeof(ClaimsPrincipal))
            {
                SecurityType = "Claims";

                IEnumerable <ClaimAttribute> claimAttributes = typeof(T).GetCustomAttributes <ClaimAttribute>();

                foreach (ClaimAttribute claimAttribute in claimAttributes)
                {
                    if (Claims.ContainsKey(claimAttribute.Verb))
                    {
                        Claims[claimAttribute.Verb].Add(claimAttribute.Claim);
                    }
                    else
                    {
                        Claims.Add(claimAttribute.Verb, new List <Claim>()
                        {
                            claimAttribute.Claim
                        });
                    }
                }

                if (!Claims.ContainsKey("POST"))
                {
                    Claims.Add("POST", new List <Claim>()
                    {
                        new Claim("Role", "Administrator")
                    });
                }
                if (!Claims.ContainsKey("PATCH"))
                {
                    Claims.Add("PATCH", new List <Claim>()
                    {
                        new Claim("Role", "Administrator")
                    });
                }
                if (!Claims.ContainsKey("DELETE"))
                {
                    Claims.Add("DELETE", new List <Claim>()
                    {
                        new Claim("Role", "Administrator")
                    });
                }
            }
            else
            {
                SecurityType = "Roles";
                PostRoles    = typeof(T).GetCustomAttribute <PostRolesAttribute>()?.Roles ?? "Administrator";
                GetRoles     = typeof(T).GetCustomAttribute <GetRolesAttribute>()?.Roles ?? "";
                PatchRoles   = typeof(T).GetCustomAttribute <PatchRolesAttribute>()?.Roles ?? "Administrator";
                DeleteRoles  = typeof(T).GetCustomAttribute <DeleteRolesAttribute>()?.Roles ?? "Administrator";
            }
            CustomView  = typeof(T).GetCustomAttribute <CustomViewAttribute>()?.CustomView ?? "";
            ViewOnly    = typeof(T).GetCustomAttribute <ViewOnlyAttribute>()?.ViewOnly ?? false;
            AllowSearch = typeof(T).GetCustomAttribute <AllowSearchAttribute>()?.AllowSearch ?? false;

            SearchSettings = typeof(T).GetCustomAttribute <AdditionalFieldSearchAttribute>();
            Take           = typeof(T).GetCustomAttribute <ReturnLimitAttribute>()?.Limit ?? null;

            // Custom View Models are ViewOnly.
            ViewOnly = ViewOnly || CustomView != String.Empty;

            RootQueryRestrictionAttribute rqra = typeof(T).GetCustomAttribute <RootQueryRestrictionAttribute>();

            if (rqra != null)
            {
                RootQueryRestriction = new RecordRestriction(rqra.FilterExpression, rqra.Parameters.ToArray());
            }
        }