Exemplo n.º 1
0
        public async Task <IActionResult> EditClient(
            Guid?siteId,
            string clientId = null)
        {
            var selectedSite = await siteManager.GetSiteForDataOperations(siteId);

            if (!string.IsNullOrEmpty(clientId))
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, sr["{0} - Edit Client"], selectedSite.SiteName);
            }

            var model = new ClientEditViewModel();

            model.SiteId           = selectedSite.Id.ToString();
            model.NewClient.SiteId = model.SiteId;
            if (!string.IsNullOrEmpty(clientId))
            {
                var client = await clientsManager.FetchClient(model.SiteId, clientId);

                model.CurrentClient = new ClientItemViewModel(model.SiteId, client);
            }

            if (model.CurrentClient == null)
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, sr["{0} - New Client"], selectedSite.SiteName);
                var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext);
                currentCrumbAdjuster.KeyToAdjust  = "EditClient";
                currentCrumbAdjuster.AdjustedText = sr["New Client"];
                currentCrumbAdjuster.AddToContext();
            }


            return(View(model));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> CountryEdit(
            Guid?countryId,
            int returnPageNumber = 1
            )
        {
            GeoCountryViewModel model;

            if ((countryId != null) && (countryId.Value != Guid.Empty))
            {
                ViewData["Title"] = sr["Edit Country"];
                var country = await dataManager.FetchCountry(countryId.Value);

                model = GeoCountryViewModel.FromIGeoCountry(country);

                var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext);
                currentCrumbAdjuster.KeyToAdjust    = "CountryEdit";
                currentCrumbAdjuster.AdjustedText   = sr["Edit Country"];
                currentCrumbAdjuster.ViewFilterName = NamedNavigationFilters.Breadcrumbs; // this is default but showing here for readers of code
                currentCrumbAdjuster.AddToContext();
            }
            else
            {
                ViewData["Title"] = sr["New Country"];
                model             = new GeoCountryViewModel();
            }

            model.ReturnPageNumber = returnPageNumber;

            return(View(model));
        }
Exemplo n.º 3
0
        //[Authorize(Roles = "Admins")]
        public async Task <ActionResult> UserEdit(
            int userId,
            Guid?siteGuid
            )
        {
            ISiteSettings selectedSite;

            // only server admin site can edit other sites settings
            if ((siteGuid.HasValue) && (siteGuid.Value != Guid.Empty) && (siteGuid.Value != siteManager.CurrentSite.SiteGuid) && (siteManager.CurrentSite.IsServerAdminSite))
            {
                selectedSite = await siteManager.Fetch(siteGuid.Value);

                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, "{0} - Manage User", selectedSite.SiteName);
            }
            else
            {
                selectedSite      = siteManager.CurrentSite;
                ViewData["Title"] = "Manage User";
            }


            EditUserViewModel model = new EditUserViewModel();

            model.SiteGuid = selectedSite.SiteGuid;

            ISiteUser user = await UserManager.Fetch(selectedSite.SiteId, userId);

            if (user != null)
            {
                model.UserId      = user.UserId;
                model.UserGuid    = user.UserGuid;
                model.Email       = user.Email;
                model.FirstName   = user.FirstName;
                model.LastName    = user.LastName;
                model.LoginName   = user.UserName;
                model.DisplayName = user.DisplayName;

                model.AccountApproved  = user.AccountApproved;
                model.Comment          = user.Comment;
                model.EmailConfirmed   = user.EmailConfirmed;
                model.IsLockedOut      = user.IsLockedOut;
                model.LastActivityDate = user.LastActivityDate;
                model.LastLoginDate    = user.LastLoginDate;
                model.TimeZoneId       = user.TimeZoneId;

                if (user.DateOfBirth > DateTime.MinValue)
                {
                    model.DateOfBirth = user.DateOfBirth;
                }


                NavigationNodeAdjuster currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext);
                currentCrumbAdjuster.KeyToAdjust    = "UserEdit";
                currentCrumbAdjuster.AdjustedText   = user.DisplayName;
                currentCrumbAdjuster.ViewFilterName = NamedNavigationFilters.Breadcrumbs; // this is default but showing here for readers of code
                currentCrumbAdjuster.AddToContext();
            }

            return(View(model));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> StateEdit(
            Guid countryId,
            Guid?stateId,
            int crp = 1,
            int returnPageNumber = 1
            )
        {
            if (countryId == Guid.Empty)
            {
                return(RedirectToAction("CountryListPage"));
            }

            GeoZoneViewModel model;

            if ((stateId.HasValue) && (stateId.Value != Guid.Empty))
            {
                var state = await dataManager.FetchGeoZone(stateId.Value);

                if ((state != null) && (state.CountryId == countryId))
                {
                    model = GeoZoneViewModel.FromIGeoZone(state);

                    var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext);
                    currentCrumbAdjuster.KeyToAdjust    = "StateEdit";
                    currentCrumbAdjuster.AdjustedText   = model.Name;
                    currentCrumbAdjuster.ViewFilterName = NamedNavigationFilters.Breadcrumbs; // this is default but showing here for readers of code
                    currentCrumbAdjuster.AddToContext();
                }
                else
                {
                    // invalid guid provided
                    return(RedirectToAction("CountryListPage", new { pageNumber = crp }));
                }
            }
            else
            {
                model           = new GeoZoneViewModel();
                model.CountryId = countryId;
            }

            model.ReturnPageNumber            = returnPageNumber;
            model.CountryListReturnPageNumber = crp;

            var country = await dataManager.FetchCountry(countryId);

            model.CountryName = country.Name;

            var stateListCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext);

            stateListCrumbAdjuster.KeyToAdjust    = "StateListPage";
            stateListCrumbAdjuster.AdjustedText   = string.Format(sr["{0} States"], model.CountryName);
            stateListCrumbAdjuster.ViewFilterName = NamedNavigationFilters.Breadcrumbs; // this is default but showing here for readers of code
            stateListCrumbAdjuster.AddToContext();

            return(View(model));
        }
Exemplo n.º 5
0
        protected void SelectUser(User user)
        {
            var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext)
            {
                KeyToAdjust  = "UserView",
                AdjustedText = user.Username
            };

            currentCrumbAdjuster.AddToContext();
        }
Exemplo n.º 6
0
        protected void SelectGame(Game game)
        {
            var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext)
            {
                KeyToAdjust  = "GameView",
                AdjustedText = game.Id.ToString()
            };

            currentCrumbAdjuster.AddToContext();
        }
Exemplo n.º 7
0
        protected void SelectAchievement(DiscordMafia.Achievement.Achievement achievement)
        {
            var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext)
            {
                KeyToAdjust  = "AchievementView",
                AdjustedText = achievement.GetName(language)
            };

            currentCrumbAdjuster.AddToContext();
        }
Exemplo n.º 8
0
        public virtual async Task <ActionResult> ChangeUserPassword(
            Guid userId,
            Guid?siteId
            )
        {
            if (!UIOptions.AllowAdminsToChangeUserPasswords)
            {
                return(RedirectToAction("Index"));
            }
            if (userId == Guid.Empty)
            {
                return(RedirectToAction("Index"));
            }


            var selectedSite = await SiteManager.GetSiteForDataOperations(siteId);

            // only server admin site can edit other sites users
            if (selectedSite.Id != SiteManager.CurrentSite.Id)
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, StringLocalizer["{0} - Change User Password"], selectedSite.SiteName);
            }
            else
            {
                ViewData["Title"] = StringLocalizer["Change User Password"];
            }

            var user = await UserManager.Fetch(selectedSite.Id, userId);

            if (user == null)
            {
                return(RedirectToAction("Index"));
            }


            var model = new ChangeUserPasswordViewModel
            {
                SiteId      = selectedSite.Id,
                UserId      = user.Id,
                DisplayName = user.DisplayName,
                Email       = user.Email
            };

            var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext)
            {
                KeyToAdjust  = "UserEdit",
                AdjustedText = user.DisplayName
            };

            currentCrumbAdjuster.AddToContext();

            return(View(model));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> StateListPage(
            Guid?countryId,
            int pageNumber = 1,
            int pageSize   = -1,
            int crp        = 1
            )
        {
            if (!countryId.HasValue)
            {
                return(RedirectToAction("CountryListPage"));
            }

            var itemsPerPage = uiOptions.DefaultPageSize_StateList;

            if (pageSize > 0)
            {
                itemsPerPage = pageSize;
            }

            var model = new StateListPageViewModel();

            var country = await dataManager.FetchCountry(countryId.Value);

            model.Country = GeoCountryViewModel.FromIGeoCountry(country);
            model.States  = await dataManager.GetGeoZonePage(countryId.Value, pageNumber, itemsPerPage);

            model.Paging.CurrentPage  = pageNumber;
            model.Paging.ItemsPerPage = itemsPerPage;
            model.Paging.TotalItems   = await dataManager.GetGeoZoneCount(countryId.Value);

            model.CountryListReturnPageNumber = crp;

            // below we are just manipiulating the bread crumbs
            var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext);

            currentCrumbAdjuster.KeyToAdjust  = "StateListPage";
            currentCrumbAdjuster.AdjustedText = string.Format(sr["{0} States"], model.Country.Name);
            currentCrumbAdjuster.AdjustedUrl  = Request.Path.ToString()
                                                + "?countryId=" + country.Id.ToString()
                                                + "&crp=" + crp.ToInvariantString();
            currentCrumbAdjuster.ViewFilterName = NamedNavigationFilters.Breadcrumbs; // this is default but showing here for readers of code
            currentCrumbAdjuster.AddToContext();

            var countryListCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext);

            countryListCrumbAdjuster.KeyToAdjust = "CountryListPage";
            countryListCrumbAdjuster.AdjustedUrl = Request.Path.ToString().Replace("StateListPage", "CountryListPage")
                                                   + "?pageNumber=" + crp.ToInvariantString();
            countryListCrumbAdjuster.AddToContext();

            return(View(model));
        }
Exemplo n.º 10
0
        public async Task <IActionResult> EditApiResource(
            Guid?siteId,
            string apiName = null)
        {
            var selectedSite = await _siteManager.GetSiteForDataOperations(siteId);

            if (!string.IsNullOrEmpty(apiName))
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, sr["{0} - Edit API Resource"], selectedSite.SiteName);
            }

            var model = new ApiEditViewModel();

            model.SiteId        = selectedSite.Id.ToString();
            model.NewApi.SiteId = model.SiteId;
            if (!string.IsNullOrEmpty(apiName))
            {
                var apiResource = await _apiManager.FetchApiResource(model.SiteId, apiName);

                model.CurrentApi = apiResource;
            }

            if (model.CurrentApi == null)
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, sr["{0} - New API Resource"], selectedSite.SiteName);
                var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext);
                currentCrumbAdjuster.KeyToAdjust  = "EditApiResource";
                currentCrumbAdjuster.AdjustedText = sr["New API Resource"];
                currentCrumbAdjuster.AddToContext();
            }
            else
            {
                model.NewApiClaim.SiteId   = model.SiteId;
                model.NewApiClaim.ApiName  = model.CurrentApi.Name;
                model.NewApiSecret.SiteId  = model.SiteId;
                model.NewApiSecret.ApiName = model.CurrentApi.Name;
                model.NewScope.SiteId      = model.SiteId;
                model.NewScope.ApiName     = model.CurrentApi.Name;
            }

            return(View(model));
        }
Exemplo n.º 11
0
        public async Task <IActionResult> RoleEdit(
            Guid?siteId,
            Guid?roleId)
        {
            var selectedSite = await _siteManager.GetSiteForDataOperations(siteId, true);

            // only server admin site can edit other sites settings
            if (selectedSite.Id != _siteManager.CurrentSite.Id)
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, _sr["{0} - New Role"], selectedSite.SiteName);
            }
            else
            {
                ViewData["Title"] = _sr["New Role"];
            }

            var model = new RoleViewModel
            {
                SiteId = selectedSite.Id
            };

            if (roleId.HasValue)
            {
                var role = await _roleManager.FindByIdAsync(roleId.Value.ToString());

                if ((role != null) && (role.SiteId == selectedSite.Id))
                {
                    model             = RoleViewModel.FromISiteRole(role);
                    ViewData["Title"] = _sr["Edit Role"];
                    var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext)
                    {
                        KeyToAdjust    = "RoleEdit",
                        AdjustedText   = _sr["Edit Role"],
                        ViewFilterName = NamedNavigationFilters.Breadcrumbs // this is default but showing here for readers of code
                    };
                    currentCrumbAdjuster.AddToContext();
                }
            }

            return(View(model));
        }
        public async Task <IActionResult> EditResource(
            Guid?siteId,
            string resourceName = null)
        {
            var selectedSite = await siteManager.GetSiteForDataOperations(siteId);

            if (!string.IsNullOrEmpty(resourceName))
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, sr["{0} - Edit Identity Resource"], selectedSite.SiteName);
            }

            var model = new IdentityEditViewModel();

            model.SiteId             = selectedSite.Id.ToString();
            model.NewResource.SiteId = model.SiteId;
            model.NewClaim.SiteId    = model.SiteId;
            if (!string.IsNullOrEmpty(resourceName))
            {
                var resource = await idManager.FetchIdentityResource(model.SiteId, resourceName);

                model.CurrentResource = resource;
            }

            if (model.CurrentResource == null)
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, sr["{0} - New Identity Resource"], selectedSite.SiteName);
                var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext);
                currentCrumbAdjuster.KeyToAdjust  = "EditIdentityResource";
                currentCrumbAdjuster.AdjustedText = sr["New Identity Resource"];
                currentCrumbAdjuster.AddToContext();
            }
            else
            {
                model.NewClaim.SiteId       = model.SiteId;
                model.NewClaim.ResourceName = model.CurrentResource.Name;
            }

            return(View(model));
        }
Exemplo n.º 13
0
        public IActionResult Roles(string modeId = null)
        {
            ViewData["Title"] = "Роли";
            var modeRegex = new Regex(@"^[a-zA-Z0-9\-]+$");

            if (modeId != null && !modeRegex.IsMatch(modeId))
            {
                return(NotFound());
            }

            ViewBag.ModeSettings = new GameSettings(settings, modeId);
            if (modeId != null)
            {
                var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext)
                {
                    KeyToAdjust  = "HelpGamemodeView",
                    AdjustedText = modeId
                };
                currentCrumbAdjuster.AddToContext();
                ViewData["Title"] = $"Роли режима {modeId}";
            }
            return(View(from r in RoleInfo.AvailableRoles group r by r.Role.Team into g orderby g.Key select g));
        }
Exemplo n.º 14
0
        public async Task <IActionResult> CountryEdit(
            Guid?guid,
            int returnPageNumber = 1,
            bool partial         = false)
        {
            ViewBag.Title = "Edit Country";

            GeoCountryViewModel model;

            if ((guid != null) && (guid.Value != Guid.Empty))
            {
                IGeoCountry country = await dataManager.FetchCountry(guid.Value);

                model = GeoCountryViewModel.FromIGeoCountry(country);

                NavigationNodeAdjuster currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext);
                currentCrumbAdjuster.KeyToAdjust    = "CountryEdit";
                currentCrumbAdjuster.AdjustedText   = "Edit Country";
                currentCrumbAdjuster.ViewFilterName = NamedNavigationFilters.Breadcrumbs; // this is default but showing here for readers of code
                currentCrumbAdjuster.AddToContext();
            }
            else
            {
                ViewBag.Title = "New Country";
                model         = new GeoCountryViewModel();
            }

            model.ReturnPageNumber = returnPageNumber;


            if (partial)
            {
                return(PartialView("CountryEditPartial", model));
            }

            return(View(model));
        }
Exemplo n.º 15
0
        public virtual async Task <ActionResult> UserEdit(
            Guid userId,
            Guid?siteId
            )
        {
            if (userId == Guid.Empty)
            {
                return(RedirectToAction("Index"));
            }

            ViewData["ReturnUrl"] = Request.Path + Request.QueryString;
            var selectedSite = await SiteManager.GetSiteForDataOperations(siteId);

            // only server admin site can edit other sites settings
            if (selectedSite.Id != SiteManager.CurrentSite.Id)
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, StringLocalizer["{0} - Manage User"], selectedSite.SiteName);
            }
            else
            {
                ViewData["Title"] = StringLocalizer["Manage User"];
            }



            var model = new EditUserViewModel
            {
                SiteId = selectedSite.Id
            };

            var user = await UserManager.Fetch(selectedSite.Id, userId);

            if (user != null)
            {
                model.UserId          = user.Id;
                model.Email           = user.Email;
                model.FirstName       = user.FirstName;
                model.LastName        = user.LastName;
                model.Username        = user.UserName;
                model.DisplayName     = user.DisplayName;
                model.AccountApproved = user.AccountApproved;
                model.Comment         = user.Comment;
                model.EmailConfirmed  = user.EmailConfirmed;
                model.IsLockedOut     = user.IsLockedOut;
                model.LastLoginDate   = user.LastLoginUtc;
                model.TimeZoneId      = user.TimeZoneId;
                model.WebSiteUrl      = user.WebSiteUrl;
                model.AvatarUrl       = user.AvatarUrl;

                if (string.IsNullOrEmpty(model.TimeZoneId))
                {
                    model.TimeZoneId = await TimeZoneIdResolver.GetSiteTimeZoneId();
                }
                model.AllTimeZones = TimeZoneHelper.GetTimeZoneList().Select(x =>
                                                                             new SelectListItem
                {
                    Text     = x,
                    Value    = x,
                    Selected = model.TimeZoneId == x
                });

                if (user.DateOfBirth > DateTime.MinValue)
                {
                    model.DateOfBirth = user.DateOfBirth;
                }

                model.UserClaims = await UserManager.GetClaimsAsync((SiteUser)user);

                model.UserRoles = await UserManager.GetRolesAsync((SiteUser)user);


                var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext)
                {
                    KeyToAdjust    = "UserEdit",
                    AdjustedText   = user.DisplayName,
                    ViewFilterName = NamedNavigationFilters.Breadcrumbs // this is default but showing here for readers of code
                };
                currentCrumbAdjuster.AddToContext();
            }

            var viewName = await CustomUserInfo.GetUserEditViewName(UserManager.Site, HttpContext);

            await CustomUserInfo.HandleUserEditGet(
                UserManager.Site,
                model,
                HttpContext,
                ViewData);

            return(View(viewName, model));
        }
Exemplo n.º 16
0
        public virtual async Task <ActionResult> UserActivity(
            Guid userId,
            Guid?siteId,
            int pageNumber = 1,
            int pageSize   = 10
            )
        {
            if (userId == Guid.Empty)
            {
                return(RedirectToAction("Index"));
            }

            var selectedSite = await SiteManager.GetSiteForDataOperations(siteId);

            var user = await UserManager.Fetch(selectedSite.Id, userId);

            if (user == null)
            {
                return(RedirectToAction("Index"));
            }

            // only server admin site can edit other sites settings
            if (selectedSite.Id != SiteManager.CurrentSite.Id)
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, StringLocalizer["{0} - User Activity - {1}"], selectedSite.SiteName, user.Email);
            }
            else
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, StringLocalizer["User Activity - {0}"], user.Email);
            }

            var model = new UserActivityViewModel
            {
                SiteId                  = selectedSite.Id,
                UserId                  = user.Id,
                CreatedUtc              = user.CreatedUtc,
                DisplayName             = user.DisplayName,
                Email                   = user.Email,
                AvatarUrl               = user.AvatarUrl,
                FirstName               = user.FirstName,
                LastLoginUtc            = user.LastLoginUtc,
                LastName                = user.LastName,
                LastPassswordChangenUtc = user.LastPasswordChangeUtc,
                TimeZoneId              = await TimeZoneIdResolver.GetUserTimeZoneId(),
                Locations               = await UserManager.GetUserLocations(
                    selectedSite.Id,
                    userId,
                    pageNumber,
                    pageSize
                    ),

                TwoFactor = user.TwoFactorEnabled,
                Logins    = await UserManager.GetLoginsAsync(user as SiteUser)
            };

            if (!string.IsNullOrWhiteSpace(user.TimeZoneId))
            {
                model.UserTimeZone = user.TimeZoneId;
            }
            else
            {
                model.UserTimeZone = UserManager.Site.TimeZoneId;
            }


            var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext)
            {
                KeyToAdjust    = "UserActivity",
                AdjustedText   = string.Format(CultureInfo.CurrentUICulture, StringLocalizer["Activity - {0}"], user.Email),
                ViewFilterName = NamedNavigationFilters.Breadcrumbs // this is default but showing here for readers of code
            };

            currentCrumbAdjuster.AddToContext();

            return(View(model));
        }
Exemplo n.º 17
0
        public async Task <IActionResult> RoleEdit(
            Guid?siteId,
            Guid?roleId)
        {
            var selectedSite = await _siteManager.GetSiteForDataOperations(siteId, true);

            // only server admin site can edit other sites settings
            if (selectedSite.Id != _siteManager.CurrentSite.Id)
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, _sr["{0} - New Role"], selectedSite.SiteName);
            }
            else
            {
                ViewData["Title"] = _sr["New Role"];
            }

            var model = new RoleViewModel
            {
                SiteId = selectedSite.Id
            };

            if (roleId.HasValue)
            {
                var role = await _roleManager.FindByIdAsync(roleId.Value.ToString());

                if ((role != null) && (role.SiteId == selectedSite.Id))
                {
                    var rejectReasons = new List <string>();
                    foreach (var guard in _roleGuards)
                    {
                        var rejectReason = await guard.GetEditRejectReason(selectedSite.Id, role.RoleName);

                        if (!string.IsNullOrWhiteSpace(rejectReason))
                        {
                            rejectReasons.Add(rejectReason);
                        }
                    }
                    if (rejectReasons.Count > 0)
                    {
                        var alertMessage = string.Join("<br />", rejectReasons.ToArray());

                        this.AlertDanger(alertMessage, true);

                        return(RedirectToAction("Index", new { siteId = selectedSite.Id }));
                    }


                    model             = RoleViewModel.FromISiteRole(role);
                    ViewData["Title"] = _sr["Edit Role"];
                    var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext)
                    {
                        KeyToAdjust    = "RoleEdit",
                        AdjustedText   = _sr["Edit Role"],
                        ViewFilterName = NamedNavigationFilters.Breadcrumbs // this is default but showing here for readers of code
                    };
                    currentCrumbAdjuster.AddToContext();
                }
            }

            return(View(model));
        }
Exemplo n.º 18
0
        public async Task <ActionResult> UserEdit(
            Guid userId,
            Guid?siteId
            )
        {
            if (userId == Guid.Empty)
            {
                return(RedirectToAction("Index"));
            }

            ViewData["ReturnUrl"] = Request.Path + Request.QueryString;
            ISiteSettings selectedSite;

            // only server admin site can edit other sites settings
            if ((siteId.HasValue) && (siteId.Value != Guid.Empty) && (siteId.Value != siteManager.CurrentSite.Id) && (siteManager.CurrentSite.IsServerAdminSite))
            {
                selectedSite = await siteManager.Fetch(siteId.Value);

                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, sr["{0} - Manage User"], selectedSite.SiteName);
            }
            else
            {
                selectedSite      = siteManager.CurrentSite;
                ViewData["Title"] = sr["Manage User"];
            }

            var model = new EditUserViewModel();

            model.SiteId = selectedSite.Id;

            var user = await UserManager.Fetch(selectedSite.Id, userId);

            if (user != null)
            {
                model.UserId          = user.Id;
                model.Email           = user.Email;
                model.FirstName       = user.FirstName;
                model.LastName        = user.LastName;
                model.Username        = user.UserName;
                model.DisplayName     = user.DisplayName;
                model.AccountApproved = user.AccountApproved;
                model.Comment         = user.Comment;
                model.EmailConfirmed  = user.EmailConfirmed;
                model.IsLockedOut     = user.IsLockedOut;
                model.LastLoginDate   = user.LastLoginUtc;
                model.TimeZoneId      = user.TimeZoneId;
                if (string.IsNullOrEmpty(model.TimeZoneId))
                {
                    model.TimeZoneId = await timeZoneIdResolver.GetSiteTimeZoneId();
                }
                model.AllTimeZones = tzHelper.GetTimeZoneList().Select(x =>
                                                                       new SelectListItem
                {
                    Text     = x,
                    Value    = x,
                    Selected = model.TimeZoneId == x
                });

                if (user.DateOfBirth > DateTime.MinValue)
                {
                    model.DateOfBirth = user.DateOfBirth;
                }

                model.UserClaims = await UserManager.GetClaimsAsync((SiteUser)user);


                var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext);
                currentCrumbAdjuster.KeyToAdjust    = "UserEdit";
                currentCrumbAdjuster.AdjustedText   = user.DisplayName;
                currentCrumbAdjuster.ViewFilterName = NamedNavigationFilters.Breadcrumbs; // this is default but showing here for readers of code
                currentCrumbAdjuster.AddToContext();
            }

            return(View(model));
        }
Exemplo n.º 19
0
        public async Task <IActionResult> StateListPage(
            Guid?countryGuid,
            int pageNumber = 1,
            int pageSize   = -1,
            int crp        = 1,
            bool ajaxGrid  = false,
            bool partial   = false)
        {
            if (!countryGuid.HasValue)
            {
                return(RedirectToAction("CountryListPage"));
            }

            ViewBag.Title = "State List Administration";
            int itemsPerPage = uiOptions.DefaultPageSize_StateList;

            if (pageSize > 0)
            {
                itemsPerPage = pageSize;
            }

            StateListPageViewModel model = new StateListPageViewModel();

            IGeoCountry country = await dataManager.FetchCountry(countryGuid.Value);

            model.Country = GeoCountryViewModel.FromIGeoCountry(country);
            model.States  = await dataManager.GetGeoZonePage(countryGuid.Value, pageNumber, itemsPerPage);

            model.Paging.CurrentPage  = pageNumber;
            model.Paging.ItemsPerPage = itemsPerPage;
            model.Paging.TotalItems   = await dataManager.GetGeoZoneCount(countryGuid.Value);

            model.CountryListReturnPageNumber = crp;

            // below we are just manipiulating the bread crumbs
            NavigationNodeAdjuster currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext);

            currentCrumbAdjuster.KeyToAdjust  = "StateListPage";
            currentCrumbAdjuster.AdjustedText = model.Country.Name + " States";
            currentCrumbAdjuster.AdjustedUrl  = Request.Path.ToString()
                                                + "?countryGuid=" + country.Guid.ToString()
                                                + "&crp=" + crp.ToInvariantString();
            currentCrumbAdjuster.ViewFilterName = NamedNavigationFilters.Breadcrumbs; // this is default but showing here for readers of code
            currentCrumbAdjuster.AddToContext();

            NavigationNodeAdjuster countryListCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext);

            countryListCrumbAdjuster.KeyToAdjust = "CountryListPage";
            countryListCrumbAdjuster.AdjustedUrl = Request.Path.ToString().Replace("StateListPage", "CountryListPage")
                                                   + "?pageNumber=" + crp.ToInvariantString();
            countryListCrumbAdjuster.AddToContext();

            if (ajaxGrid)
            {
                return(PartialView("StateListGridPartial", model));
            }

            if (partial)
            {
                return(PartialView("StateListPagePartial", model));
            }


            return(View(model));
        }
Exemplo n.º 20
0
        public async Task <IActionResult> StateEdit(
            Guid countryGuid,
            Guid?guid,
            int crp = 1,
            int returnPageNumber = 1
            )
        {
            if (countryGuid == Guid.Empty)
            {
                return(RedirectToAction("CountryListPage"));
            }

            //int returnPage = 1;
            //if (returnPageNumber.HasValue) { returnPage = returnPageNumber.Value; }

            ViewBag.Title = "Edit State";

            GeoZoneViewModel model;

            if ((guid.HasValue) && (guid.Value != Guid.Empty))
            {
                IGeoZone state = await dataManager.FetchGeoZone(guid.Value);

                if ((state != null) && (state.CountryGuid == countryGuid))
                {
                    model         = GeoZoneViewModel.FromIGeoZone(state);
                    model.Heading = "Edit State";
                }
                else
                {
                    // invalid guid provided
                    return(RedirectToAction("CountryListPage", new { pageNumber = crp }));
                }
            }
            else
            {
                model             = new GeoZoneViewModel();
                model.Heading     = "Create New State";
                model.CountryGuid = countryGuid;
            }

            model.ReturnPageNumber            = returnPageNumber;
            model.CountryListReturnPageNumber = crp;

            IGeoCountry country = await dataManager.FetchCountry(countryGuid);

            model.Country = GeoCountryViewModel.FromIGeoCountry(country);

            NavigationNodeAdjuster currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext);

            currentCrumbAdjuster.KeyToAdjust    = "StateEdit";
            currentCrumbAdjuster.AdjustedText   = model.Heading;
            currentCrumbAdjuster.ViewFilterName = NamedNavigationFilters.Breadcrumbs; // this is default but showing here for readers of code
            currentCrumbAdjuster.AddToContext();

            //var node = SiteMaps.Current.FindSiteMapNodeFromKey("StateEdit");
            //if (node != null)
            //{
            //    node.Title = model.Heading;
            //    var parent = node.ParentNode;
            //    if (parent != null)
            //    {
            //        parent.Title = model.Country.Name + " States";

            //    }
            //}

            return(View(model));
        }