本文整理汇总了C#中IndexViewModel类的典型用法代码示例。如果您正苦于以下问题:C# IndexViewModel类的具体用法?C# IndexViewModel怎么用?C# IndexViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IndexViewModel类属于命名空间,在下文中一共展示了IndexViewModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Index
//
// GET: /Manage/Index
public async Task<ActionResult> Index(ManageMessageId? message)
{
ViewBag.StatusMessage =
message == ManageMessageId.ChangePasswordSuccess
? Resources.Manage.ManageMessage_ChangePasswordSuccess
: message == ManageMessageId.SetPasswordSuccess
? Resources.Manage.ManageMessage_SetPasswordSuccess
: message == ManageMessageId.SetTwoFactorSuccess
? Resources.Manage.ManageMessage_SetTwoFactorSuccess
: message == ManageMessageId.Error
? Resources.Manage.ManageMessage_Error
: message == ManageMessageId.AddPhoneSuccess
? Resources.Manage.ManageMessage_AddPhoneSuccess
: message == ManageMessageId.RemovePhoneSuccess
? Resources.Manage.ManageMessage_RemovePhoneSuccess
: "";
var userId = User.Identity.GetUserId<int>();
var model = new IndexViewModel
{
HasPassword = HasPassword(),
PhoneNumber = await _userManager.GetPhoneNumberAsync(userId),
TwoFactor = await _userManager.GetTwoFactorEnabledAsync(userId),
Logins = await _userManager.GetLoginsAsync(userId),
BrowserRemembered =
await _authenticationManager.TwoFactorBrowserRememberedAsync(User.Identity.GetUserId())
};
return View(model);
}
示例2: UpdateUser
public ActionResult UpdateUser(IndexViewModel model)
{
var UserName = User.Identity.GetUserName();
if (ModelState.IsValid)
{
var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
ApplicationUser user = context.Users.Where(u => u.UserName.Equals(UserName, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
user.Address = model.Address;
user.City = model.City;
user.State = model.State;
user.PostalCode = model.PostalCode;
try
{
context.SaveChanges();
return RedirectToAction("Index", new { Message = ManageMessageId.UpdateSuccess });
}
catch
{
ViewBag.ResultMessage = "Update failed !";
return RedirectToAction("Index", new { Message = ManageMessageId.UpdateFailed });
}
}
return RedirectToAction("Index", new { Message = ManageMessageId.UpdateFailed });
}
示例3: Index
public ActionResult Index()
{
var topOrganizations = this.Cache.Get(
"topOrganizations",
() => this.organizations
.GetTopOrganizations(GlobalConstants.TopOrganizationsCount)
.To<OrganizationViewModel>()
.ToList(),
30 * 60);
var usersCount = this.Cache.Get(
"usersCount",
() => this.users.GetAll().Count(),
30 * 60);
var organizationsCount = this.Cache.Get(
"usersCount",
() => this.organizations.GetAll().Count(),
30 * 60);
var model = new IndexViewModel()
{
Organizations = topOrganizations,
UsersCount = usersCount,
OrganizationsCount = organizationsCount
};
return this.View(model);
}
示例4: Index
public ActionResult Index(int page = 1)
{
if (page < 1)
{
page = 1;
}
var userId = this.User.Identity.GetUserId();
var universitiesList = this.universities
.All()
.Where(u => u.DirectorId == userId)
.To<UniversityViewModel>()
.OrderBy(u => u.Name);
var universitiesCount = universitiesList.Count();
var modelUniversities = universitiesList.Skip((page - 1) * PageSize).Take(PageSize).ToList();
var model = new IndexViewModel()
{
Page = page,
UniversitiesCount = universitiesCount,
Universities = modelUniversities,
PageSize = PageSize
};
return this.View(model);
}
示例5: Index
public ActionResult Index()
{
var newestEvents = this.Cache.Get(
WebControllerConstants.NewestEventsCacheKey,
() => this.events
.GetNewestEvents(WebControllerConstants.HomePageNewestEventsCount)
.To<EventIndexViewModel>()
.ToList(),
30 * 60);
var newestArticles = this.Cache.Get(
WebControllerConstants.NewestArticlesCacheKey,
() => this.articles
.GetNewestEvents(WebControllerConstants.HomePageNewestArticlesCount)
.To<ArticleIndexViewModel>()
.ToList(),
30 * 60);
var viewModel = new IndexViewModel
{
Events = newestEvents,
Articles = newestArticles
};
return this.View(viewModel);
}
示例6: Index
// GET: /Manage/Index
public async Task<ActionResult> Index(ManageMessageId? message)
{
this.ViewBag.StatusMessage = message == ManageMessageId.ChangePasswordSuccess
? "Your password has been changed."
: message == ManageMessageId.SetPasswordSuccess
? "Your password has been set."
: message == ManageMessageId.SetTwoFactorSuccess
? "Your two-factor authentication provider has been set."
: message == ManageMessageId.Error
? "An error has occurred."
: message == ManageMessageId.AddPhoneSuccess
? "Your phone number was added."
: message == ManageMessageId.RemovePhoneSuccess
? "Your phone number was removed."
: message == ManageMessageId.AddCityError
? "There is no such city in the database"
: string.Empty;
this.SetCurrentUser();
var model = new IndexViewModel
{
User = this.Mapper.Map<UserViewModel>(this.CurrentUser)
};
return this.View(model);
}
示例7: Index
public async Task<ActionResult> Index(Guid id, IndexViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
var data = new KeyDatesOverrideData
{
AcknowledgedDate = model.AcknowledgedDate.AsDateTime(),
CommencementDate = model.CommencementDate.AsDateTime(),
CompleteDate = model.CompleteDate.AsDateTime(),
ConsentedDate = model.ConsentedDate.AsDateTime(),
ConsentValidFromDate = model.ConsentValidFromDate.AsDateTime(),
ConsentValidToDate = model.ConsentValidToDate.AsDateTime(),
NotificationId = id,
NotificationReceivedDate = model.NotificationReceivedDate.AsDateTime(),
ObjectedDate = model.ObjectedDate.AsDateTime(),
WithdrawnDate = model.WithdrawnDate.AsDateTime(),
TransmittedDate = model.TransmittedDate.AsDateTime()
};
await mediator.SendAsync(new SetExportKeyDatesOverride(data));
return RedirectToAction("Index", "KeyDates");
}
示例8: Index
//
// GET: /Manage/Index
public async Task<ActionResult> Index(ManageMessageId? message)
{
ViewBag.StatusMessage =
message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
: message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
: message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set."
: message == ManageMessageId.Error ? "An error has occurred."
: message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added."
: message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed."
: "";
var userId = User.Identity.GetUserId();
var user = db.Users.Find(userId);
var model = new IndexViewModel
{
FirstName = user.FirstName,
LastName = user.LastName,
Email = user.Email,
AdminRights = user.HasAdminRights,
BudgetItems = user.Household.BudgetItems.Where(m => m.CreatorId == userId),
HasPassword = HasPassword(),
PhoneNumber = await UserManager.GetPhoneNumberAsync(userId),
TwoFactor = await UserManager.GetTwoFactorEnabledAsync(userId),
Logins = await UserManager.GetLoginsAsync(userId),
BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId)
};
return View(model);
}
示例9: Index
public async Task<IActionResult> Index(ManageMessageId? message = null)
{
ViewData["StatusMessage"] =
message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
: message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
: message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set."
: message == ManageMessageId.Error ? "An error has occurred."
: message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added."
: message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed."
: "";
var user = await GetCurrentUserAsync();
if (user == null)
{
return View("Error");
}
var model = new IndexViewModel
{
HasPassword = await _userManager.HasPasswordAsync(user),
PhoneNumber = await _userManager.GetPhoneNumberAsync(user),
TwoFactor = await _userManager.GetTwoFactorEnabledAsync(user),
Logins = await _userManager.GetLoginsAsync(user),
BrowserRemembered = await _signInManager.IsTwoFactorClientRememberedAsync(user)
};
return View(model);
}
示例10: Index
//
// GET: /Manage/Index
public async Task<ActionResult> Index(ManageMessageId? message)
{
ViewBag.StatusMessage =
message == ManageMessageId.ChangePasswordSuccess
? "Your password has been changed."
: message == ManageMessageId.SetPasswordSuccess
? "Your password has been set."
: message == ManageMessageId.SetTwoFactorSuccess
? "Your two-factor authentication provider has been set."
: message == ManageMessageId.Error
? "An error has occurred."
: message == ManageMessageId.AddPhoneSuccess
? "Your phone number was added."
: message == ManageMessageId.RemovePhoneSuccess
? "Your phone number was removed."
: "";
var userId = User.Identity.GetUserId();
var model = new IndexViewModel
{
HasPassword = HasPassword(),
PhoneNumber = await UserManager.GetPhoneNumberAsync(userId),
TwoFactor = await UserManager.GetTwoFactorEnabledAsync(userId),
Logins = await UserManager.GetLoginsAsync(userId),
BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId)
};
return View(model);
}
示例11: Index
public ActionResult Index()
{
if (this.User.Identity.IsAuthenticated)
{
this.ViewData.Add("Username", this.User.Identity);
}
var ingredients = this.ingredients.GetRandomIngredients(3)
.To<IngredientViewModel>()
.ToList();
var recipes = this.recipes.GetMostLikedRecipes(3)
.To<RecipeViewModel>()
.ToList();
var articles = this.articles.GetNewestArticles(3)
.To<ArticleViewModel>()
.ToList();
// var articles = this.Cache.Get("articles",
// () => this.articles.GetNewestArticles(3)
// .To<ArticleViewModel>()
// .ToList(),
// 15 * 60);
var viewModel = new IndexViewModel
{
Ingredients = ingredients,
Recipes = recipes,
Articles = articles
};
return this.View(viewModel);
}
示例12: Index
public ActionResult Index(string notebook)
{
var viewModel = new IndexViewModel();
var noteStore = Evernote.GetNoteStore(User.Identity.Name);
foreach (var n in noteStore.listNotebooks(User.Identity.Name))
{
var notesCount = noteStore.findNoteCounts(User.Identity.Name, new NoteFilter { NotebookGuid = n.Guid }, false).NotebookCounts.First().Value;
var notebookViewModel = new IndexViewModel.Notebook
{
Id = n.Guid,
Name = n.Name,
NotesCount = notesCount
};
if (n.Guid == notebook)
foreach (var note in noteStore.findNotes(User.Identity.Name, new NoteFilter { NotebookGuid = n.Guid }, 0, 1000).Notes)
notebookViewModel.Notes.Add(new IndexViewModel.Note
{
Id = note.Guid,
Name = note.Title,
UpdateDate = new DateTime(1970, 1, 1).AddMilliseconds(note.Updated)
});
viewModel.Notebooks.Add(notebookViewModel);
}
return View(viewModel);
}
示例13: Index
public virtual ActionResult Index()
{
SetNavigationHierarchy(GetLieDetectorOrThiefNavigationItems());
var likelyThiefSuggestions = _documentSession.Query<LikelyThief>().OrderByDescending(x => x.AdditionDate).ToList();
var lastComments =
_documentSession.Query<LieDetectorOrThiefCommentsIndex.IndexResult, LieDetectorOrThiefCommentsIndex>().
OrderByDescending(x => x.DateTime).
Take(10).
AsProjection<LieDetectorOrThiefCommentsIndex.IndexResult>().
ToList();
var lastCommentViewModels = lastComments.Select(
x =>
{
var actionResult = MVC.LieDetectorOrThief.LikelyThief.GetLikelyThief(new LikelyThief() { Id = x.Id });
return new GetCommentsFeedViewModel(actionResult, x.Id.GetNumericPart(), x.DateTime, x.Author, x.Text);
}).
ToList();
var hasRightToAcceptLikelyThieves = SecurityUser.HasRight(RightType.AcceptLikelyThiefSuggestions, Initiative);
var indexViewModel = new IndexViewModel(likelyThiefSuggestions, lastCommentViewModels, hasRightToAcceptLikelyThieves);
return View(indexViewModel);
}
示例14: Index
public async Task<ActionResult> Index()
{
var model = new IndexViewModel();
model.Areas = await GetAreas();
return View(model);
}
示例15: Index
//
// GET: /Manage/Index
public async Task<ActionResult> Index(ManageMessageId? message)
{
ViewBag.StatusMessage =
message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
: message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
: message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set."
: message == ManageMessageId.Error ? "An error has occurred."
: message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added."
: message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed."
: message == ManageMessageId.ChangeTelephoneSuccess ? "Číslo bylo úspěšně změněno."
: message == ManageMessageId.ChangeMailSuccess ? "E-mail byl úspěšně změněn."
: "";
var userId = User.Identity.GetUserId();
var user = await UserManager.FindByIdAsync(userId);
var model = new IndexViewModel
{
//HasPassword = HasPassword(),
//PhoneNumber = await UserManager.GetPhoneNumberAsync(userId),
//TwoFactor = await UserManager.GetTwoFactorEnabledAsync(userId),
//Logins = await UserManager.GetLoginsAsync(userId),
//BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId)
Telephone = user.Telephone,
Email = user.Email
};
return View(model);
}