public HomeViewModel UpdatePage() { try { HomeViewModel model = new HomeViewModel(); model.Articles = dbHelper.GetAllArticles(); model.Categories = dbHelper.GetAllCategories(); try { model.Categories.Where(c => c.Name == "Uncategorized").Single().Name = _localizer["Uncategorized"]; } catch { } string activeUserName = User.Identity.Name; JasperSite.Models.Database.User currentUser = dbHelper.GetAllUsers().Where(u => u.Username.Trim().ToLower() == activeUserName.Trim().ToLower()).Single(); model.CurrentUser = currentUser; return(model); } catch { HomeViewModel model = new HomeViewModel(); model.Articles = null; model.Categories = null; return(model); } }
public UsersViewModel UpdatePage() { try { List <User> users = _dbHelper.GetAllUsers(); UsersViewModel model = new UsersViewModel(); model.Users = users; // Active user will be in the first row string activeUserName = User.Identity.Name; JasperSite.Models.Database.User currentUser = users.Where(u => u.Username.Trim().ToLower() == activeUserName.Trim().ToLower()).Single(); users.Remove(currentUser); users.Insert(0, currentUser); return(model); } catch { UsersViewModel model = new UsersViewModel(); model.Users = null; return(model); } }