csharp 创建了一个新的模型属性(但不在DB中)并在客户端显示它。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 创建了一个新的模型属性(但不在DB中)并在客户端显示它。相关的知识,希望对你有一定的参考价值。
<div class="form-group">
<label class="label-col col-xs-4 control-label" for="PasswordExpiration">Password Expiration</label>
<div class="col-xs-8 dateSpan">
<span id="PasswordExpiration" name="PasswordExpiration">@(Model.ExpirationDate)</span>
</div>
</div>
public string ExpirationDate { get; set; }
public ActionResult editView(long clientUserId)
{
ClientUser clientUser = clientUserRepository.findById(clientUserId);
MembershipUser membershipUser = clientMembershipProvider.retrieveUser(clientUser.User.UserName);
//defined it here and set it below while setting it to a string
DateTime expirationDate = membershipUser.LastPasswordChangedDate.AddDays(90);
ViewBag.MenuTab = MenuTabs.ADMIN_CLIENTS;
ViewBag.SubMenu = MenuTabs.ADMIN_CLIENT_USER_CONTRACTS;
ViewBag.ClientId = clientUser.ClientId;
ViewBag.Title = "Client User";
ViewBag.ClientAccount = clientUser.Client.AccountName;
CuEdit model = new CuEdit();
model.IsApiEnabled = clientConfigurationRepository.isApiEnabled(clientUser.ClientId);
model.AvailableSalutations = enumLookupRepository.findAllSalutations();
model.AvailableStates = stateRepository.findAllSelectListItem();
model.ClientUserId = clientUserId;
model.ClientId = clientUser.ClientId;
model.HasEditRole = MembershipHelper.verifyRoles(webRequestState.UserName, StaffRoles.OrClientEdit,staffRoleProvider);
model.IsEnabled = clientUser.IsEnabled;
model.UserName = clientUser.User.UserName;
model.EmailAddress = clientUser.EmailAddress;
model.Title = clientUser.Title;
model.Salutation = clientUser.Salutation;
model.FirstName = clientUser.FirstName;
model.LastName = clientUser.LastName;
model.Status = membershipUser.IsApproved;
model.PhoneNumber = clientUser.PhoneNumber;
model.Extension = clientUser.Extension;
model.AddressLine1 = clientUser.AddressLine1;
model.AddressLine2 = clientUser.AddressLine2;
model.City = clientUser.City;
model.State = clientUser.State;
model.ZipCode = clientUser.ZipCode;
model.ChangePassword = clientUser.ChangePassword;
model.Roles = clientRoleProvider.GetRolesForUser(clientUser.User.UserName);
model.AvailableRoles = ClientRoles.AllRoles;
model.SmsPhone = clientUser.SmsPhone;
model.FacebookLink = clientUser.FacebookLink;
model.TwitterLink = clientUser.TwitterLink;
model.SterlingWestUserName = clientUser.SterlingWestUserName;
model.TwitterPassword = clientUser.TwitterPassword;
model.FacebookPassword = clientUser.FacebookPassword;
// had to set it to a string and use "d" as the formatting type
model.ExpirationDate = expirationDate.ToString("d");
return View(model);
}
以上是关于csharp 创建了一个新的模型属性(但不在DB中)并在客户端显示它。的主要内容,如果未能解决你的问题,请参考以下文章
csharp 循环遍历两个列表,检查条件,创建新的db对象实例(记录),保存到db以及运行存储过程。
csharp 在DB上下文中设置十进制属性的精度
db.create_all() 在磁盘上但不在内存中创建模式
csharp 使用SharePoint客户端对象模型从SharePoint用户配置文件服务获取信息。这使用了对Profile DB的查询
Laravel 8 all() 函数不会将 db 值映射到模型属性
DB2 的数据模型工具