Click here to Skip to main content
15,064,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
----------------------------------
//This is the Class********
----------------------------------
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;
namespace OvhokEMarket.Models.OnlyModels.Account.Security
{
    public class IdentityUserExtraEntity : IdentityUser
    {
        [NotMapped]
        public string EncryptedId { get; set; }
}
}

------------------------------------------------------------------------------
//This is the controller********
------------------------------------------------------------------------------
        [HttpGet]
        public async Task<IActionResult> ListRoles()
        {
        
            ViewBag.SubscribeRemainingDays = CheckPlanOfClient_RemainingDays();//To Display remainging days in view.

            ListRolesViewModels listRolesViewModels = new ListRolesViewModels();
             listRolesViewModels.IdentityRoleExtraEntityLIST = roleManager.Roles;
            foreach (var RolesName in listRolesViewModels.IdentityRoleExtraEntityLIST)
            {
                RolesName.EncryptedId = protector.Protect(RolesName.Id.ToString());//Encrypted data to pass in Notmapped attribute
             
            }
         
            return View(listRolesViewModels);
        }


What I have tried:

I am trying to pass both Notmapped attribute and ViewBag value. But it seems that ViewBag override Notmapped value as null while passing to view.

How do pass both value to view?

Thanks you in advance.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900