v9.8.2018.0605   由DataReader直接映射实体列表,以支持netstandard的MySql和SQLite,且提升性能
大石头 authored at 2018-06-05 00:45:23
6.41 KiB
X
@model XCode.Membership.IUser
@using System.Linq
@using System.Reflection
@using XCode
@using XCode.Configuration
@using NewLife.Cube.Entity;
@{
    var fact = EntityFactory.CreateOperate(ViewData.ModelMetadata.ModelType);
    var user = Model as IUser;

    var ms = NewLife.Web.OAuthConfig.Current.Items.Where(e => !e.AppID.IsNullOrEmpty()).ToList();
    var binds = ViewBag.Binds as IList<UserConnect>;
}
<div class="row">
    <div class="col-md-12">
        <div class="form-horizontal">
            @if (ViewBag.StatusMessage != null)
            {
                <div class="alert alert-success alert-dismissible text-center" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <strong>@ViewBag.StatusMessage</strong>
                </div>
            }
            @using (Html.BeginForm("Info", null, new { id = Model[fact.Unique.Name] }))
            {
                @Html.ValidationSummary()
                if (!user.Avatar.IsNullOrEmpty())
                {
                    <div class="form-group">
                        <img src="@user.Avatar" />
                    </div>
                }
                <div class="form-group">
                    <label class="control-label col-md-2">名称</label>
                    <div class="input-group col-md-6">
                        <input value="@user.Name" class="col-xs-12 col-sm-8 col-md-6 col-lg-4" disabled="disabled" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-2">密码</label>
                    <div class="input-group col-md-6">
                        @Html.ForEditor("Password")
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-2">显示名</label>
                    <div class="input-group col-md-6">
                        @Html.ForEditor("DisplayName")
                        @Html.ForDescription("DisplayName")
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-2">性别</label>
                    <div class="input-group col-md-6">
                        @Html.ForEditor("Sex", user.Sex)
                        @Html.ForDescription("Sex")
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-2">邮件</label>
                    <div class="input-group col-md-6">
                        @Html.ForEditor("Mail")
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-2">手机</label>
                    <div class="input-group col-md-6">
                        @Html.ForEditor("Mobile")
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-2">代码</label>
                    <div class="input-group col-md-6">
                        @Html.ForEditor("Code")
                        @Html.ForDescription("Code")
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-2">角色</label>
                    <div class="input-group col-md-2">
                        @(user.Roles.Join(",", r => r + ""))
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-2">登录次数</label>
                    <div class="input-group col-md-2">
                        @user.Logins
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-2">最后登录</label>
                    <div class="input-group col-md-2">
                        @user.LastLogin.ToFullString("")
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-2">最后登录IP</label>
                    <div class="input-group col-md-6">
                        @user.LastLoginIP
                    </div>
                </div>
                if (ms.Count > 0)
                {
                    <div class="form-group">
                        <label class="control-label col-md-2">第三方绑定</label>
                        <div class="input-group col-md-6">
                            <ul>
                                @foreach (var mi in ms)
                                {
                                    var uc = binds.FirstOrDefault(e => e.Enable && e.Provider.EqualIgnoreCase(mi.Name));
                                    if (uc != null)
                                    {
                                        <li>
                                            <span>@mi.Name(已绑定)</span>
                                            <a href="~/Sso/UnBind/@mi.Name" title="取消绑定 @mi.Name">取消绑定</a>
                                        </li>
                                    }
                                    else
                                    {
                                        <li>
                                            <span>@mi.Name(未绑定)</span>
                                            <a href="~/Sso/Bind/@mi.Name" title="绑定 @mi.Name">去绑定</a>
                                        </li>
                                    }
                                }
                            </ul>
                        </div>
                    </div>
                }
                <div class="clearfix form-actions">
                    <label class="control-label col-md-4"></label>
                    <button type="submit" class="btn btn-success btn-sm"><i class="glyphicon glyphicon-save" )"></i><strong>保存</strong></button>
                    <button type="button" class="btn btn-danger btn-sm" onclick="history.go(-1);"><i class="glyphicon glyphicon-remove"></i><strong>取消</strong></button>
                </div>
            }
        </div>
    </div>
</div>