public StateListPageViewModel()
        {
            Country = new GeoCountryViewModel();
            States = new List<IGeoZone>();
            Paging = new PaginationSettings();

        }
 public static GeoCountryViewModel FromIGeoCountry(IGeoCountry geoCountry)
 {
     GeoCountryViewModel model = new GeoCountryViewModel();
     model.Id = geoCountry.Id;
     model.Name = geoCountry.Name;
     model.ISOCode2 = geoCountry.ISOCode2;
     model.ISOCode3 = geoCountry.ISOCode3;
     return model;
 }
Exemplo n.º 3
0
        public static GeoCountryViewModel FromIGeoCountry(IGeoCountry geoCountry)
        {
            GeoCountryViewModel model = new GeoCountryViewModel();

            model.Id       = geoCountry.Id;
            model.Name     = geoCountry.Name;
            model.ISOCode2 = geoCountry.ISOCode2;
            model.ISOCode3 = geoCountry.ISOCode3;
            return(model);
        }
Exemplo n.º 4
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.º 5
0
        public async Task<IActionResult> CountryEdit(
            GeoCountryViewModel model,
            int returnPageNumber = 1)
        {
            ViewBag.Title = "Edit Country";

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

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

            bool result = await dataManager.Save(model);

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

            return RedirectToAction("CountryListPage", new { pageNumber = returnPageNumber });

        }
Exemplo n.º 6
0
 public GeoZoneViewModel()
 {
     Country = new GeoCountryViewModel();
 }
Exemplo n.º 7
0
 public StateListPageViewModel()
 {
     Country = new GeoCountryViewModel();
     States  = new List <IGeoZone>();
     Paging  = new PaginationSettings();
 }
Exemplo n.º 8
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.º 9
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 });

        }
Exemplo n.º 10
0
 public GeoZoneViewModel()
 {
     Country = new GeoCountryViewModel();
 }