public List <FunctionSelected> SetOrderIncomeProperty(ReSetFunction reSetFunction, Function function)
        {
            List <FunctionSelected> functionSelecteds = new List <FunctionSelected>();
            var rf = reSetFunction.GetType();

            if (function != null)
            {
                var      f   = function.GetType();
                object[] rfs = rf.GetProperties();

                foreach (PropertyInfo pi in rfs)
                {
                    if (pi.Name.Contains("OpName"))
                    {
                        var propertyInfo = f.GetProperty(pi.Name);
                        if (propertyInfo != null && pi.GetValue(reSetFunction) != null &&
                            !string.IsNullOrWhiteSpace(pi.GetValue(reSetFunction).ToString()))
                        {
                            functionSelecteds.Add(new FunctionSelected()
                            {
                                Name     = pi.GetValue(reSetFunction).ToString(),
                                Selected = (pi.GetValue(reSetFunction).ToString() == propertyInfo.GetValue(function).ToString())
                            });
                        }
                    }
                }
            }
            else
            {
                object[] rfs = rf.GetProperties();

                foreach (PropertyInfo pi in rfs)
                {
                    if (pi.Name.Contains("OpName"))
                    {
                        if (pi.GetValue(reSetFunction) != null && !string.IsNullOrWhiteSpace(pi.GetValue(reSetFunction).ToString()))
                        {
                            functionSelecteds.Add(new FunctionSelected()
                            {
                                Name     = pi.GetValue(reSetFunction).ToString(),
                                Selected = false
                            });
                        }
                    }
                }
            }

            return(functionSelecteds);
        }
        public async Task <ServiceResponseBase> Create(AppMenuViewModel vm)
        {
            try
            {
                var strategy = _accessManagementContext.Database.CreateExecutionStrategy();
                var isExist  = await _accessManagementContext.AppMenu.AnyAsync(o => o.Code == vm.Code);

                if (isExist)
                {
                    return(new ServiceResponseBase()
                    {
                        Status = Status.error, Message = "存在重复编码!"
                    });
                }
                var appMenu = Mapper.Map <AppMenu>(vm);
                await _accessManagementContext.AppMenu.AddAsync(appMenu);

                var reSetFunction = new ReSetFunction()
                {
                    Name = appMenu.Name,
                    Code = appMenu.Code
                };
                await _accessManagementContext.ReSetFunction.AddAsync(reSetFunction);

                await _accessManagementContext.SaveChangesAsync();

                return(new ServiceResponseBase()
                {
                    Status = Status.ok
                });
            }
            catch (Exception ex)
            {
                return(new ServiceResponseBase()
                {
                    Status = Status.error, Message = ex.Message
                });
            }
        }