예제 #1
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));
        }
예제 #2
0
        public async Task <IActionResult> CountryEdit(
            GeoCountryViewModel model,
            int returnPageNumber = 1)
        {
            ViewBag.Title = "Edit Country";

            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            bool   result;
            string successFormat;

            if (model.Guid == Guid.Empty)
            {
                successFormat = "The country <b>{0}</b> was successfully created.";
                result        = await dataManager.Add(model);
            }
            else
            {
                successFormat = "The country <b>{0}</b> was successfully updated.";
                result        = await dataManager.Update(model);
            }

            if (result)
            {
                this.AlertSuccess(string.Format(successFormat,
                                                model.Name), true);
            }

            return(RedirectToAction("CountryListPage", new { pageNumber = returnPageNumber }));
        }
예제 #3
0
        public async Task <IActionResult> CountryEdit(
            GeoCountryViewModel model,
            int returnPageNumber = 1)
        {
            ViewData["Title"] = sr["Edit Country"];

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            string successFormat;

            if (model.Id == Guid.Empty)
            {
                successFormat = sr["The country {0} was successfully created."];
                await dataManager.Add(model);
            }
            else
            {
                successFormat = sr["The country {0} was successfully updated."];
                await dataManager.Update(model);
            }

            this.AlertSuccess(string.Format(successFormat,
                                            model.Name), true);

            return(RedirectToAction("CountryListPage", new { pageNumber = returnPageNumber }));
        }
예제 #4
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));
        }
예제 #5
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);
                }
                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.Country = GeoCountryViewModel.FromIGeoCountry(country);

            var 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();

            return(View(model));
        }
예제 #6
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));
        }
예제 #7
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));
        }
예제 #8
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));
        }