Ejemplo n.º 1
0
        public async Task <RoleResponseVM> Get([FromQuery] RoleRequestVM requestVM)
        {
            ApplicationRole request = requestVM.Convert();

            ApplicationRole response = await this.RoleApplication.Get(request);

            RoleResponseVM responseVM = response.Convert(base.UseDefaultLanguage);

            return(responseVM);
        }
        /// <summary>
        /// Convert converts ApplicationRole object to RoleResponseVM object.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static RoleResponseVM Convert(this ApplicationRole model, bool useLanguage)
        {
            var vm = new RoleResponseVM
            {
                RoleId              = model.RoleId,
                RoleName            = useLanguage.GetLanguageText(model.RoleName, model.RoleNameTranslation),
                RoleNameCode        = model.RoleNameCode,
                RoleNameTranslation = model.RoleNameTranslation,
                Active              = model.Active,
                ClaimGroups         = new List <ClaimGroupResponseVM>()
            };

            if (model.ClaimGroups != null)
            {
                foreach (var claimGroup in model.ClaimGroups)
                {
                    vm.ClaimGroups.Add(claimGroup.Convert(useLanguage));
                }
            }

            return(vm);
        }