Ejemplo n.º 1
0
        public static SettingsDTO Create(Settings settings, ApplicationDbContext dbContext)
        {
            var dto = new SettingsDTO
            {
                RootUrl = settings.RootUrl,
                IsLocal = System.Web.HttpContext.Current.Request.IsLocal
            };

            // add roles
            using (var roleStore = new RoleStore <AppRole, Guid, AppUserRole>(dbContext))
                using (var roleManager = new RoleManager <AppRole, Guid>(roleStore))
                {
                    foreach (var role in roleManager.Roles.ToList())
                    {
                        Roles roleEnum;
                        var   parseResult = Enum.TryParse(role.Name, out roleEnum);
                        if (!parseResult)
                        {
                            throw new InvalidCastException("Invalid role in SettingsDTO.Create: " + role.Name);
                        }

                        var roleDTO = new RoleDTO {
                            Id = role.Id, Name = roleEnum.ToString()
                        };
                        // override role names with friendly names here, e.g. roleDTO.Name = "Project Manager";

                        dto.Roles.Add(roleDTO);
                    }
                }

            return(dto);
        }
Ejemplo n.º 2
0
        public static SettingsDTO Create(Settings settings)
        {
            //var Enum1 = new List<Enum1DTO>();
            //foreach (Enum1 enum in Enum.GetValues(typeof(Enum1)))
            //    Enum1.Add(new Enum1DTO { Id = (int)status, Name = status.ToString() });

            var dto = new SettingsDTO
            {
                RootUrl = settings.RootUrl
                          //xxx = settings.xxx
            };

            return(dto);
        }
Ejemplo n.º 3
0
 public void Hydrate(Settings settings, SettingsDTO settingsDTO)
 {
 }
Ejemplo n.º 4
0
 public void Hydrate(Settings settings, SettingsDTO settingsDTO)
 {
     //settings.xxx = settingsDTO.xxx;
 }