public IActionResult Regions(string[] SelectedRegions, RegionsViewModel model)
        {
            var Apprenticeship = _session.GetObject <Apprenticeship>("selectedApprenticeship");

            var employerBased = Apprenticeship.ApprenticeshipLocations.FirstOrDefault(x =>
                                                                                      x.ApprenticeshipLocationType == ApprenticeshipLocationType.EmployerBased);

            if (SelectedRegions.Any())
            {
                if (employerBased != null)
                {
                    employerBased.Regions = SelectedRegions;
                }
                else
                {
                    Apprenticeship.ApprenticeshipLocations.Add(CreateRegionLocation(SelectedRegions, null));
                }
            }
            else
            {
                Apprenticeship.ApprenticeshipLocations.RemoveAll(x => x.ApprenticeshipLocationType == ApprenticeshipLocationType.EmployerBased);
            }

            _session.SetObject("selectedApprenticeship", Apprenticeship);

            return(RedirectToAction("Summary", "Apprenticeships"));
        }
Beispiel #2
0
        public ActionResult Delete(int[] ids)
        {
            if (ids == null || !ids.Any())
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var model = new RegionsViewModel();

            model.Regions = new List <RegionViewModel>();

            foreach (int id in ids)
            {
                Region region = regionService.Find(id);
                if (region == null)
                {
                    continue;
                }
                if (ViewBag.CountryCode == null)
                {
                    ViewBag.CountryCode = region.CountryCode;
                }

                model.Regions.Add(new RegionViewModel
                {
                    Id   = region.Id,
                    Name = region.Name,
                });
            }
            return(View(model));
        }
        public IActionResult Regions()
        {
            var model = new RegionsViewModel();

            model.ChooseRegion = new ChooseRegionModel
            {
                Regions = _courseService.GetRegions(),
                UseNationalComponent = false
            };

            var Apprenticeship = _session.GetObject <Apprenticeship>("selectedApprenticeship");
            var employerBased  = Apprenticeship?.ApprenticeshipLocations.FirstOrDefault(x =>
                                                                                        x.ApprenticeshipLocationType == ApprenticeshipLocationType.EmployerBased);

            model.ChooseRegion.HasOtherDeliveryOptions = Apprenticeship?.ApprenticeshipLocations.Any(x =>
                                                                                                     x.ApprenticeshipLocationType != ApprenticeshipLocationType.EmployerBased) ?? false;
            if (Apprenticeship != null && employerBased != null)
            {
                foreach (var selectRegionRegionItem in model.ChooseRegion.Regions.RegionItems.OrderBy(x => x.RegionName))
                {
                    foreach (var subRegionItemModel in selectRegionRegionItem.SubRegion)
                    {
                        if (employerBased.Regions.Contains(subRegionItemModel.Id))
                        {
                            subRegionItemModel.Checked = true;
                        }
                    }
                }
            }

            return(View("../Apprenticeships/Regions/Index", model));
        }
Beispiel #4
0
        public async Task <IActionResult> GetRegions(int page, int pageSize, string regionName)
        {
            var regions = await _regionService.GetAllRegionsAsync();

            var regionsViewModel = new RegionsViewModel(page, pageSize, regions, regionName, User.IsInRole("Admin"));

            return(Ok(regionsViewModel));
        }
Beispiel #5
0
        public IActionResult Index()
        {
            var parameters = new RegionQueryParameters();

            var result       = _regionService.Find(new services.types.Pager(1));
            var mappedResult = _mapper.Map <PagedResult <RegionPartialViewModel> >(result);
            var viewModel    = new RegionsViewModel(parameters, mappedResult);

            return(View(viewModel));
        }
        public JsonResult Post([FromBody] RegionsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json(new { message = Validation.getValidationErrors(model) }));
            }
            RegionsModel items = new RegionsModel(model);

            bool isSaved = regionsService.Save(items);

            return(Json(new { message = isSaved ? "Сохранено" : "Не cохранено" }));
        }
Beispiel #7
0
        public async Task <IActionResult> GetRegions(int page, int pageSize, string regionName)
        {
            string recordKey = "Regions_" + DateTime.Now.ToString("yyyyMMdd_hhmm");
            IEnumerable <RegionDTO> regions = await _cache.GetRecordAsync <IEnumerable <RegionDTO> >(recordKey);

            if (regions is null)
            {
                regions = await _regionService.GetAllRegionsAsync();

                await _cache.SetRecordAsync(recordKey, regions);
            }
            var regionsViewModel = new RegionsViewModel(page, pageSize, regions, regionName, User.IsInRole(Roles.Admin));

            return(Ok(regionsViewModel));
        }
Beispiel #8
0
        // GET: MappyController
        public async Task <IActionResult> Index()

        {
            RegionsViewModel vm = new RegionsViewModel();



            List <Region> Regions = new List <Region>();


            using (var client = new HttpClient())

            {
                //Passing service base url

                client.BaseAddress = new Uri("https://localhost:44356/");



                client.DefaultRequestHeaders.Clear();

                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));



                //Sending request to find web api REST service resource GetDepartments using HttpClient

                HttpResponseMessage Res = await client.GetAsync("regions");



                //Checking the response is successful or not which is sent using HttpClient

                if (Res.IsSuccessStatusCode)

                {
                    var ObjResponse = Res.Content.ReadAsStringAsync().Result;

                    vm.Regions = JsonConvert.DeserializeObject <List <Region> >(ObjResponse);
                }

                //returning the student list to view

                return(View(vm));
            }

            return(View(vm));
        }
        public JsonResult Put(int id, [FromBody] RegionsViewModel model)
        {
            if (id < 1 || model == null)
            {
                return(Json(new { message = "Не cохранено" }));
            }
            if (!ModelState.IsValid)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json(new { message = Validation.getValidationErrors(model) }));
            }
            RegionsModel item = new RegionsModel(model)
            {
                Id = id
            };
            bool isSaved = regionsService.Update(item, id);

            return(Json(new { message = isSaved ? "Сохранено" : "Не cохранено" }));
        }
Beispiel #10
0
        public ActionResult Test()
        {
            NorthwindEntities1    db = new NorthwindEntities1();
            List <SelectListItem> listSelectListItems = new List <SelectListItem>();

            foreach (Region regions in db.Regions)
            {
                SelectListItem selectList = new SelectListItem()
                {
                    Text     = regions.RegionDescription.ToString(),
                    Value    = regions.RegionID.ToString(),
                    Selected = false
                };
                listSelectListItems.Add(selectList);
            }
            RegionsViewModel regionViewModel = new RegionsViewModel()
            {
                Regions = listSelectListItems
            };

            return(View(regionViewModel));
        }
Beispiel #11
0
        static void InitModules()
        {
            ModuleManager.DefaultManager.Register(
                Regions.Navigation,
                new DevExpress.Mvvm.ModuleInjection.Module(Modules.Dashboard,
                                                           () => NavigationItemViewModel.Create(Modules.Dashboard, "Sales", "Revenue" + Environment.NewLine + "Snapshots", ResourceImageHelper.GetResourceImage("Sales.png")),
                                                           typeof(NavigationItemView)));
            ModuleManager.DefaultManager.Register(
                Regions.Navigation,
                new DevExpress.Mvvm.ModuleInjection.Module(Modules.Products,
                                                           () => NavigationItemViewModel.Create(Modules.Products, "Products", "Revenue" + Environment.NewLine + "by Products", ResourceImageHelper.GetResourceImage("Products.png")),
                                                           typeof(NavigationItemView)));
            ModuleManager.DefaultManager.Register(
                Regions.Navigation,
                new DevExpress.Mvvm.ModuleInjection.Module(Modules.Sectors,
                                                           () => NavigationItemViewModel.Create(Modules.Sectors, "Sectors", "Revenue" + Environment.NewLine + "by Sectors", ResourceImageHelper.GetResourceImage("Sectors.png")),
                                                           typeof(NavigationItemView)));
            ModuleManager.DefaultManager.Register(
                Regions.Navigation,
                new DevExpress.Mvvm.ModuleInjection.Module(Modules.Regions,
                                                           () => NavigationItemViewModel.Create(Modules.Regions, "Regions", "Revenue" + Environment.NewLine + "by Regions", ResourceImageHelper.GetResourceImage("Regions.png")),
                                                           typeof(NavigationItemView)));
            ModuleManager.DefaultManager.Register(
                Regions.Navigation,
                new DevExpress.Mvvm.ModuleInjection.Module(Modules.Channels,
                                                           () => NavigationItemViewModel.Create(Modules.Channels, "Channels", "Revenue" + Environment.NewLine + "by Sales Channels", ResourceImageHelper.GetResourceImage("Channels.png")),
                                                           typeof(NavigationItemView)));

            ModuleManager.DefaultManager.Register(Regions.Main, new DevExpress.Mvvm.ModuleInjection.Module(Modules.Dashboard, () => SalesDashboardViewModel.Create(), typeof(SalesDashboard)));
            ModuleManager.DefaultManager.Register(Regions.Main, new DevExpress.Mvvm.ModuleInjection.Module(Modules.Products, () => ProductsViewModel.Create(), typeof(ProductsView)));
            ModuleManager.DefaultManager.Register(Regions.Main, new DevExpress.Mvvm.ModuleInjection.Module(Modules.Sectors, () => SectorsViewModel.Create(), typeof(SectorsView)));
            ModuleManager.DefaultManager.Register(Regions.Main, new DevExpress.Mvvm.ModuleInjection.Module(Modules.Regions, () => RegionsViewModel.Create(), typeof(RegionsView)));
            ModuleManager.DefaultManager.Register(Regions.Main, new DevExpress.Mvvm.ModuleInjection.Module(Modules.Channels, () => ChannelsViewModel.Create(), typeof(ChannelsView)));

            ModuleManager.DefaultManager.Inject(Regions.Navigation, Modules.Dashboard);
            ModuleManager.DefaultManager.Inject(Regions.Navigation, Modules.Products);
            ModuleManager.DefaultManager.Inject(Regions.Navigation, Modules.Sectors);
            ModuleManager.DefaultManager.Inject(Regions.Navigation, Modules.Regions);
            ModuleManager.DefaultManager.Inject(Regions.Navigation, Modules.Channels);

            ModuleManager.DefaultManager.Inject(Regions.Main, Modules.Dashboard);
            ModuleManager.DefaultManager.Inject(Regions.Main, Modules.Products);
            ModuleManager.DefaultManager.Inject(Regions.Main, Modules.Sectors);
            ModuleManager.DefaultManager.Inject(Regions.Main, Modules.Regions);
            ModuleManager.DefaultManager.Inject(Regions.Main, Modules.Channels);

            ModuleManager.DefaultManager.Navigate(Regions.Navigation, Modules.Dashboard);
        }