public async Task <IActionResult> AddUserInRole(DashboardIndexViewModel model) { string inputRole = model.AddUserInRole.Role; string inputUsername = model.AddUserInRole.Username; if (this.ModelState.IsValid) { var isAdded = await this.dashboardService.IsAddedUserInRole(inputRole, inputUsername); if (isAdded) { this.TempData["Success"] = string.Format(SuccessMessages.SuccessfullyAddedUserInRole, inputUsername.ToUpper(), inputRole); } else { this.TempData["Error"] = string.Format(ErrorMessages.UserAlreadyInRole, inputUsername.ToUpper(), inputRole); } } else { this.TempData["Error"] = ErrorMessages.InvalidInputModel; } return(this.RedirectToAction("Index", "Dashboard")); }
public async Task <IActionResult> CreateRole(DashboardIndexViewModel model) { string role = model.CreateRole.Role; if (this.ModelState.IsValid) { IdentityResult result = await this.dashboardService.CreateRole(role); if (result.Succeeded) { this.TempData["Success"] = string.Format(SuccessMessages.SuccessfullyAddedRole, role); } else { this.TempData["Error"] = string.Format(ErrorMessages.RoleExist, role); } } else { this.TempData["Error"] = ErrorMessages.InvalidInputModel; return(this.RedirectToAction("Index", "Dashboard", model)); } return(this.RedirectToAction("Index", "Dashboard")); }
public ViewResult Index() { var user = _userManager.Users.FirstOrDefault(u => u.Id == _userManager.GetUserId(User)); var filmItems = _context.UserWatching.Include(f => f.FilmItem).Where(u => u.ApplicationUserId == user.Id).ToList(); var seriesWatched = filmItems.Where(f => f.FilmItem.Discriminator == "Episode").GroupBy(x => x.FilmItem.Rel_SeriesId).Select(x => new { Count = x.Count() }); var userViewings = GetUserWatched(filmItems); DashboardIndexViewModel dashboardIndexViewModel = new DashboardIndexViewModel { User = user, EpisodesWatched = userViewings.EpisodesWatched, EpisodeTimeWatched = CalculateInDays(userViewings.EpisodeTimeWatched), SeriesWatched = seriesWatched.Count(), MoviesWatched = userViewings.MoviesWatched, MovieTimeWatched = CalculateInDays(userViewings.MovieTimeWatched), RecentlyWatchedFilmItems = RecentlyWatchedFilmItems(user), UserViewingByDate = GetLast30Days(filmItems), UpcomingFilmItems = UpcomingFilmItemsFromWatchlist(user) }; UpcomingFilmItemsFromWatchlist(user); return(View(dashboardIndexViewModel)); }
public async Task <IActionResult> RemoveUserFromRole(DashboardIndexViewModel model) { if (this.ModelState.IsValid) { var username = model.RemoveUserFromRole.Username; var role = model.RemoveUserFromRole.Role; bool isRemoved = await this.dashboardService.RemoveUserFromRole(username, role); if (isRemoved) { this.TempData["Success"] = string.Format(SuccessMessages.SuccessfullyRemoveUserRole, username.ToUpper(), role); return(this.Redirect($"/Profile/{username}")); } else { this.TempData["Error"] = string.Format(ErrorMessages.UserNotInRole, username.ToUpper(), role); } } else { this.TempData["Error"] = ErrorMessages.InvalidInputModel; } return(this.RedirectToAction("Index", "Dashboard")); }
public async Task <IActionResult> Index() { var CommandLogs = await _context.CommandLogs.ToListAsync(); var model = new DashboardIndexViewModel(); model.CommandLogs = CommandLogs; return(View(model)); }
public IActionResult Index() { var model = new DashboardIndexViewModel(); model.TripsCount = this.tripsService.GetCount(); model.EventsCount = this.eventsService.GetAllEventsCount(); model.UsersCount = this.usersService.GetAllUsersCount(); return(this.View(model)); }
public IActionResult Index() { DashboardViewModel dashboard = this.dashboardService.GetDashboardInformation(); DashboardIndexViewModel model = new DashboardIndexViewModel { DashboardViewModel = dashboard, CreateRole = new CreateRoleInputModel(), }; return(this.View(model)); }
/// <summary> /// /// </summary> public async Task <IActionResult> Index() { var userId = GetCurrentUserId(); var model = new DashboardIndexViewModel { Organizations = await _organizationService.GetListByUserIdAsync(userId), User = await _userService.GetByIdAsync(userId), }; return(View(model)); }
public ActionResult Index() { var currentUserChildrenViewModels = this.mappingService.MapCollection <ChildViewModel>(this.UserProfile.Children.AsQueryable()) .ToList(); var indexViewModel = new DashboardIndexViewModel { CurrentUserChildren = currentUserChildrenViewModels }; return(this.View(indexViewModel)); }
public ActionResult Index() { var model = new DashboardIndexViewModel { MovieCount = _unitOfWork.Movie.GetCount(), UserCount = _unitOfWork.User.GetCount(), RentCount = _unitOfWork.Rent.GetCount() }; return(View(model)); }
//GET //public IActionResult DashboardFranchiseIndex() //{ // string userId = _userManager.GetUserId( User ); // var franchises = from f in _franchises.GetAllByOwnerId( userId ) select f; // var franchiseModelList = franchises.Select( f => new FranchiseIndexListingModel // { // Id = f.Id, // Nickname = f.AbbreviatedName, // Points = f.Points, // Value = f.Value, // NumberOfTrades = f.NumberOfTrades, // League = f.League, // } ).ToList(); // //var model = new FranchiseIndexModel() // //{ Franchises = franchiseModelList }; // return View( franchiseModelList ); //} public IActionResult Index(int id) { string userId = _userManager.GetUserId(User); var franchises = from f in _franchises.GetAllByOwnerId(userId) select f; var franchiseModelList = franchises.Select(f => new FranchiseIndexListingModel { Id = f.Id, Nickname = f.AbbreviatedName, Points = f.Points, Value = f.Value, NumberOfTrades = f.NumberOfTrades, League = f.League, }).ToList(); var franchiseModel = new FranchiseIndexModel() { Franchises = franchiseModelList }; if (id != 0) { ViewBag.FranchiseId = id; var playerAssignments = from pa in _players.GetFranchisePlayers(id) select pa; var playersList = playerAssignments.Select(pa => new Player { Age = pa.Player.Age, FirstName = pa.Player.FirstName, LastName = pa.Player.LastName, HitterStats = pa.Player.HitterStats, PitcherStats = pa.Player.PitcherStats, Position = pa.PlayerPosition, Team = pa.Player.Team, }).ToList(); franchiseModel.FranchisePlayers = playersList.ToList(); } else { franchiseModel.FranchisePlayers = null; } var players = _players.GetAll(); var model = new DashboardIndexViewModel { FranchiseModel = franchiseModel, Players = players.ToList() }; return(View(model)); }
public async Task <IActionResult> Index() { var model = new DashboardIndexViewModel(); var allDashboards = await _grafanaHelper.GetAllDashboardsAsync(); //model.DashboardSelectList = new SelectList(allDashboards, "Id", "Title"); model.DashboardsList = allDashboards; return(View(model)); }
public ActionResult Index() { var model = new DashboardIndexViewModel { CategoryCount = db.Categories.Count(), PostCount = db.Posts.Count(), UserCount = db.Users.Count(), CommentCount = db.Comments.Count(), }; return(View(model)); }
public IActionResult Index() { DashboardIndexViewModel model = new DashboardIndexViewModel { ContractsCount = this.contractService.GetCount(), OrdersCount = this.orderService.GetCount(), ProductsCount = this.productService.GetCount(), ProductTypesCount = this.productTypeService.GetCount(), UsersCount = this.userService.GetCount(), }; return(this.View(model)); }
public DashboardIndexViewModel GetCounts() { DashboardIndexViewModel data = new DashboardIndexViewModel() { UsersCount = this.users.All().Count(), QuestionsCount = this.questions.All().Count(), AnswersCount = this.answers.All().Count(), CategoriesCount = this.categories.All().Count(), QuizzesCount = this.quizes.All().Count(), }; return(data); }
public async Task <IActionResult> Index() { var userGuilds = await _userGuildService.GetUserGuilds(); var guilds = GetGuildDetails(userGuilds.FilterAdministrator()); var viewModel = new DashboardIndexViewModel { UserGuilds = guilds }; return(View(viewModel)); }
public async Task <ActionResult> ChangeEmail(DashboardIndexViewModel model) { using (var context = new ApplicationDbContext()) { //if (ModelState.IsValid) //{ var user = await UserManager.FindByNameAsync(User.Identity.Name); user.Email = model.Email; await UserManager.UpdateAsync(user); //} } return(RedirectToAction("Index")); }
public ActionResult Admin() { Service service = new Service(); DashboardIndexViewModel model = new DashboardIndexViewModel { Users = service.GetAllUsers() }; if (TempData["Message"] != null) { ViewBag.Message = TempData["Message"]; } ViewBag.Header = "Success!"; return(View(model)); }
public async Task <IActionResult> Index( string invalidEmail, string searchText, string searchCriteria, int page = 1, int countPerPage = PerPageDefaultValue) { var model = new DashboardIndexViewModel { NewUser = new UserInputViewModel(), CurrentPage = page, PagesCount = 0, SearchType = searchCriteria, SearchString = searchText, }; ApplicationRole role = null; if (searchCriteria == GlobalConstants.AdministratorRoleName || searchCriteria == GlobalConstants.TeacherRoleName) { role = await this.roleManager.FindByNameAsync(searchCriteria); } var userInRoleCount = await this.userService.GetAllInRolesCountAsync(searchCriteria, searchText, role?.Id); if (userInRoleCount > 0) { var users = await this.userService.GetAllInRolesPerPageAsync <UserInRoleViewModel>( page, countPerPage, searchCriteria, searchText, role?.Id); foreach (var user in users) { var appUser = await this.userManager.FindByIdAsync(user.Id); var roles = await this.userManager.GetRolesAsync(appUser); user.Role = string.Join(GlobalConstants.SplitOption, roles); } model.Users = users; model.PagesCount = (int)Math.Ceiling(userInRoleCount / (decimal)countPerPage); } model.NewUser.IsNotAdded = invalidEmail != null; model.NewUser.Email = invalidEmail ?? null; return(this.View(model)); }
public DashboardIndexViewModel GetDashboardData(int sucursalId) { var data = new DashboardIndexViewModel(); var ventas = _context.Set <Venta>().Where(x => x.Active && x.Estado != Constants.EstadoVenta.Anulado && x.DateCreated.ToLocalTime().Date == DateTime.Now.Date && x.SucursalId == sucursalId); var compras = _context.Set <Compra>().Where(x => x.Active && x.Estado != Constants.EstadoCompra.Anulado && x.DateCreated.ToLocalTime().Date == DateTime.Now.Date && x.SucursalId == sucursalId); var pedidos = _context.Set <Pedido>().Where(x => x.Active && x.Estado != Constants.EstadoPedido.Anulado && x.DateCreated.ToLocalTime().Date == DateTime.Now.Date && x.SucursalId == sucursalId); data.Ventas.CantVentas = ventas.Count(); data.Compras.CantCompras = compras.Count(); data.Pedidos.CantPedidos = pedidos.Count(); data.Ventas.MontoTotal = ventas.Sum(x => x.MontoTotal); data.Compras.MontoTotal = compras.Sum(x => x.MontoTotal); data.Pedidos.MontoTotal = pedidos.Sum(x => x.MontoTotal); data.Pedidos.PedidosDelivery = Mapper.Map <List <DashboardPedidoViewModel> >(pedidos.Where(x => x.Delivery).OrderBy(x => x.FechaEntrega)); return(data); }
// GET: Dashboards public ActionResult Index() { var viewModel = new DashboardIndexViewModel(); viewModel.CurrentUser = new AppUser(); viewModel.DashboardsList = new List <Dashboard>(); var userEmail = HttpContext.User.Identity.Name; var user = db.AppUsers.SingleOrDefault(u => u.Email == userEmail); viewModel.IsCompanyAdmin = (user.Roles.Where(r => r.Name == "CompanyAdmin")).Count() == 1; viewModel.IsSuperAdmin = (user.Roles.Where(r => r.Name == "SuperAdmin")).Count() == 1; viewModel.IsUser = (user.Roles.Where(r => r.Name == "User")).Count() == 1; if (!viewModel.IsCompanyAdmin && !viewModel.IsSuperAdmin && !viewModel.IsUser) { return(View("~/Views/Shared/Error_403.cshtml")); } viewModel.CurrentUser = user; if (viewModel.IsUser) { viewModel.DashboardsList = db.Dashboards.Where(x => x.IdDashboardAdmin == user.Id).ToList(); } else if (viewModel.IsCompanyAdmin) { viewModel.DashboardsList = db.Dashboards.Where(x => x.IdOwner == user.Id).ToList(); } if (viewModel.IsSuperAdmin) { viewModel.DashboardsList = db.Dashboards.ToList(); } if (viewModel.DashboardsList.Count == 0) { return(View("~/Views/Shared/Errors/Error_NotFound_Available_Dashboard.cshtml")); } return(View(viewModel)); }
public async Task <ActionResult> ChangePassword(DashboardIndexViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword); if (result.Succeeded) { var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); if (user != null) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); } return(RedirectToAction("Index", new { Message = ManageMessageId.ChangePasswordSuccess })); } AddErrors(result); return(View(model)); }
public async Task <IActionResult> Index() { var defaultImage = await _DataAccess.DefaultImageDataAccess.GetDefaultImageByIdBytesAync(1); var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); // will give the user's userId var tradeListings = await _DataAccess.TradeDataAccess.GetTradeListingsByUser(userId); var rating = await _DataAccess.TradeDataAccess.GetUserRating(userId); var userName = User.FindFirstValue(ClaimTypes.Name); var userInventory = await _DataAccess.UserInventoryDataAccess.GetUserInventoryByUserAsync(userId); if (userInventory == null) { userInventory = new UserInventory(); userInventory.ApplicationUserId = userId; userInventory = await _DataAccess.UserInventoryDataAccess.Upsert(userInventory); } var model = new DashboardIndexViewModel(); model.Name = userName; model.UserInventory = userInventory; model.CardMappings = await _DataAccess.CardDataAccess.GetCardMappingsForUserAsync(userInventory.Id); model.Decks = await _DataAccess.DeckDataAccess.GetDecksByUserAsync(userInventory.Id); model.DefaultImageBytes = defaultImage; model.TradeListings = tradeListings; model.Rating = rating; model.TradeOffers = await _DataAccess.TradeDataAccess.GetTradeOffersByUserAync(userId); model.Friends = await _DataAccess.UserInventoryDataAccess.GetFriends(userInventory.Id); model.BlockList = await _DataAccess.UserInventoryDataAccess.GetBlocks(userInventory.Id); return(View(model)); }
public ActionResult Index() { var user = UserManager.FindByName(User.Identity.Name); Service service = new Service(); var profileInfo = service.GetProfileInfo(user.Id); var jeepInfo = service.GetPrimaryJeepInfo(user.UserName); var memberInfo = service.GetMembership(user.UserName); var subscriptionInfo = service.GetSubscription(memberInfo.MembershipId); var subscriptionType = service.GetSubscriptionType(subscriptionInfo.SubscriptionTypeId); var settings = service.GetSettings(user.Id); var following = service.GetFriends(user.Id); var pending = service.GetPendingFriends(user.Id); var followers = service.GetFollowerFriends(user.Id); var userPending = service.GetUsersPending(user.Id); DashboardIndexViewModel model = new DashboardIndexViewModel(); model.UserProfileId = profileInfo == null ? 0 : profileInfo.UserProfileId; model.Email = user.Email; model.FirstName = profileInfo == null ? "" : profileInfo.FirstName; model.LastName = profileInfo == null ? "" : profileInfo.LastName; model.Description = profileInfo == null ? "" : profileInfo.Description; model.BirthDate = profileInfo == null ? DateTime.MinValue : Convert.ToDateTime(profileInfo.BirthDate); model.Facebook = profileInfo == null ? "" : profileInfo.Facebook; model.Twitter = profileInfo == null ? "" : profileInfo.Twitter; model.GooglePlus = profileInfo == null ? "" : profileInfo.GooglePlus; model.Website = profileInfo == null ? "" : profileInfo.Website; model.Ello = profileInfo == null ? "" : profileInfo.Ello; model.Instagram = profileInfo == null ? "" : profileInfo.Instagram; model.Avatar = profileInfo == null ? null : profileInfo.Avatar; model.SubscriptionType = subscriptionType == null ? null : subscriptionType; model.ExpirationDate = subscriptionInfo == null ? null : subscriptionInfo.ExpireDate; model.MemberSince = memberInfo == null ? null : memberInfo.MemberSince; model.PrivateStatusUpdates = settings.PrivateStatus; if (jeepInfo != null) { model.JeepProfileId = jeepInfo.VehicleProfileId; model.Manufactuer = jeepInfo == null ? "" : jeepInfo.Manufacturer; model.Make = jeepInfo == null ? "" : jeepInfo.Make; model.Model = jeepInfo == null ? "" : jeepInfo.Model; model.Year = jeepInfo == null?Convert.ToInt16(0) : Convert.ToInt16(jeepInfo.Year); model.JeepDescription = jeepInfo == null ? "" : jeepInfo.Description; model.PrimaryJeep = jeepInfo == null ? false : Convert.ToBoolean(jeepInfo.PrimaryJeep); if (jeepInfo != null) { model.Image = jeepInfo.Image; } } model.SentMessages = service.GetSentMessages(user.Id); model.Inbox = service.GetInboxMessages(user.Id); model.Followers = followers; model.Following = following; model.Pending = pending; model.UsersPending = userPending; return(View(model)); }
// GET: Sales/Dashboard public ActionResult Index(int?month, int?year) { var model = new DashboardIndexViewModel(User.Identity.Name, month ?? DateTime.Today.Month, year ?? DateTime.Today.Year); return(View(model)); }