public void Initialize(Step2ViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            Model = model;

            InitializeComponent();

            tbxPathTo.DataBindings.Add("Text", Model, "PathTo", false, DataSourceUpdateMode.OnPropertyChanged);
            cbxSaveSettings.DataBindings.Add("Checked", Model, "SaveSettings", false, DataSourceUpdateMode.OnPropertyChanged);
            cmbActionsOnCopy.DisplayMember = "Title";
            cmbActionsOnCopy.DataSource    = Model.OnCopyOptions;
            cmbActionsOnCopy.DataBindings.Add("SelectedItem", Model, "SelectedOnCopyOption", false, DataSourceUpdateMode.OnPropertyChanged);
            picOnCopyActionsDescription.DataBindings.Add("Visible", Model, "ShowSelectedOnCopyOptionDescription", false, DataSourceUpdateMode.OnPropertyChanged);

            btnSelectPathTo.Click += delegate
            {
                DialogResult result = folderBrowserDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    Model.PathTo = folderBrowserDialog.SelectedPath;
                }
            };

            btnNextStep.Click                     += delegate { Invoke(OnNextStepClick); };
            btnPreviousStep.Click                 += delegate { Invoke(OnPreviousStepClick); };
            picOnCopyActionsDescription.Click     += delegate { Invoke(OnCopyActionsDescriptionClick); };
            cmbActionsOnCopy.SelectedIndexChanged += delegate { HideOnCopyAddDescription(); };

            IsInitialized = true;
        }
Пример #2
0
        public async Task <IActionResult> Step2(Step2ViewModel model)
        {
            var currentUser = await _userManager.GetUserAsync(User);

            if (!_createManager.IsStepValid(model.Id, currentUser))
            {
                return(RedirectToAction("Step1"));
            }

            var windowImages = new List <WindowImages>();

            foreach (var file in Request.Form.Files)
            {
                windowImages.Add(new WindowImages()
                {
                    WindowId = model.Id
                });
            }
            _dbContext.WindowImages.AddRange(windowImages);
            await _dbContext.SaveChangesAsync();

            var windowImagesComplete = await _createManager.AddImagesToAzure(windowImages, Request.Form.Files);

            if (windowImagesComplete != null)
            {
                _dbContext.WindowImages.UpdateRange(windowImagesComplete);
                await _dbContext.SaveChangesAsync();

                return(Json(Url.Action("Step3", new { model.Id })));
            }
            return(View());
        }
Пример #3
0
        public ActionResult Step2(int id)
        {
            Step2ViewModel model = _listingService.GetStep2ById(id);

            model.StepsProgressModel.Step      = 2;
            model.StepsProgressModel.ListingId = id;


            if (model.Step2FlatForRent != null)
            {
                return(View("FlatForRent/Step2", model));
            }
            if (model.Step2FlatForSale != null)
            {
                return(View("FlatForSale/Step2", model));
            }
            if (model.Step2HouseForRent != null)
            {
                return(View("HouseForRent/Step2", model));
            }
            if (model.Step2HouseForSale != null)
            {
                return(View("HouseForSale/Step2", model));
            }
            if (model.Step2LandForSale != null)
            {
                return(View("LandForSale/Step2", model));
            }
            if (model.Step2RoomForRent != null)
            {
                return(View("RoomForRent/Step2", model));
            }

            return(null);
        }
Пример #4
0
        public static Step3ViewModel MapToStep3ViewModel(Step2ViewModel source)
        {
            var target = new Step3ViewModel();

            Map(source, target);
            return(target);
        }
Пример #5
0
        public async Task <IActionResult> Step2SchoolCategory(Step2ViewModel model)
        {
            ModelState.Clear();

            model.PublicSelected  = false;
            model.PrivateSelected = false;
            model.CharterSelected = false;
            model.IsHomeschooled  = false;
            if (model.SetPrivate)
            {
                model.PrivateSelected = true;
                model.SchoolList      = new SelectList(
                    await _schoolService.GetPrivateSchoolListAsync(), "Id", "Name");
            }
            else if (model.SetCharter)
            {
                model.CharterSelected = true;
                model.SchoolList      = new SelectList(
                    await _schoolService.GetCharterSchoolListAsync(), "Id", "Name");
            }
            else if (model.SetHomeschool)
            {
                model.IsHomeschooled = true;
            }
            else
            {
                model.PublicSelected = true;
            }

            model.CategorySelectionAction = nameof(Step2SchoolCategory);
            model.SchoolDistrictList      = new SelectList(
                await _schoolService.GetDistrictsAsync(true), "Id", "Name");
            model.SchoolId         = null;
            model.SchoolDistrictId = null;
            model.SchoolNotListed  = false;

            var site = await GetCurrentSiteAsync();

            PageTitle = $"{site.Name} - Join Now!";

            var programList = await _siteService.GetProgramList();

            var programViewObject = _mapper.Map <List <ProgramViewModel> >(programList);

            model.ProgramList = new SelectList(programList.ToList(), "Id", "Name");
            model.ProgramJson = Newtonsoft.Json.JsonConvert.SerializeObject(programViewObject);
            if (model.ProgramId.HasValue)
            {
                var program = await _siteService.GetProgramByIdAsync(model.ProgramId.Value);

                model.ShowAge    = program.AskAge;
                model.ShowSchool = program.AskSchool;
            }

            return(View(nameof(Step2), model));
        }
        private Step2ViewModel GetStep2(long?id)
        {
            var model = new Step2ViewModel();

            if (id.HasValue)
            {
                // Load existing data from a Service via id
                // For the example, just populating directly here...
                model.EmailAddress = "*****@*****.**";
            }

            return(model);
        }
Пример #7
0
        public Step2Presenter(IApplicationController controller, IStep2View view, Step2ViewModel model, IFolderService folderService)
            : base(controller, view)
        {
            if (folderService == null)
            {
                throw new ArgumentNullException("folderService");
            }
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            _folderService = folderService;
            _model         = model;
        }
Пример #8
0
        public async Task <IActionResult> Step2(int id)
        {
            var currentUser = await _userManager.GetUserAsync(User);

            if (!_createManager.IsStepValid(id, currentUser))
            {
                return(RedirectToAction("Step1"));
            }

            var model = new Step2ViewModel()
            {
                Id = id
            };

            return(View());
        }
Пример #9
0
        public async Task <IActionResult> Step2()
        {
            var site = await GetCurrentSiteAsync();

            if (site.SinglePageSignUp)
            {
                return(RedirectToAction("Index"));
            }
            if (!TempData.ContainsKey(TempStep1))
            {
                return(RedirectToAction("Step1"));
            }

            PageTitle = $"{site.Name} - Join Now!";

            var programList = await _siteService.GetProgramList();

            var programViewObject = _mapper.Map <List <ProgramViewModel> >(programList);
            var districtList      = await _schoolService.GetDistrictsAsync();

            if (programList.Count() > 1)
            {
                programList = programList.Prepend(new Program()
                {
                    Id = -1
                });
            }

            Step2ViewModel viewModel = new Step2ViewModel()
            {
                ProgramJson        = Newtonsoft.Json.JsonConvert.SerializeObject(programViewObject),
                ProgramList        = new SelectList(programList.ToList(), "Id", "Name"),
                SchoolDistrictList = new SelectList(districtList.ToList(), "Id", "Name")
            };

            if (programList.Count() == 1)
            {
                var programId = programList.SingleOrDefault().Id;
                var program   = await _siteService.GetProgramByIdAsync(programId);

                viewModel.ProgramId  = programList.SingleOrDefault().Id;
                viewModel.ShowAge    = program.AskAge;
                viewModel.ShowSchool = program.AskSchool;
            }

            return(View(viewModel));
        }
Пример #10
0
        public async Task <IActionResult> Step2()
        {
            var site = await GetCurrentSiteAsync();

            if (site.SinglePageSignUp)
            {
                return(RedirectToAction(nameof(Index)));
            }
            if (!TempData.ContainsKey(TempStep1))
            {
                return(RedirectToAction(nameof(Step1)));
            }

            PageTitle = _sharedLocalizer[Annotations.Title.JoinNow, site.Name];

            var programList = await _siteService.GetProgramList();

            var programViewObject = _mapper.Map <List <ProgramSettingsViewModel> >(programList);

            var viewModel = new Step2ViewModel
            {
                ProgramJson = JsonConvert.SerializeObject(programViewObject),
                ProgramList = NameIdSelectList(programList.ToList()),
                SchoolList  = NameIdSelectList(await _schoolService.GetSchoolsAsync())
            };

            if (programList.Count() == 1)
            {
                var programId = programList.Single().Id;
                var program   = await _siteService.GetProgramByIdAsync(programId);

                viewModel.ProgramId  = programList.SingleOrDefault()?.Id;
                viewModel.ShowAge    = program.AskAge;
                viewModel.ShowSchool = program.AskSchool;
            }

            return(View(viewModel));
        }
Пример #11
0
        public ActionResult Step2(Step2ViewModel model)
        {
            if (ModelState.IsValid)
            {
                _listingService.SaveListingStep2(model, User.Identity.GetUserId());
                return(RedirectToAction(nameof(Step3), new { id = model.Id }));
            }

            model.StepsProgressModel.ListingId = model.Id;
            model.StepsProgressModel.Step      = 2;

            if (model.Step2FlatForRent != null)
            {
                return(View("FlatForRent/Step2", model));
            }
            if (model.Step2FlatForSale != null)
            {
                return(View("FlatForSale/Step2", model));
            }
            if (model.Step2HouseForRent != null)
            {
                return(View("HouseForRent/Step2", model));
            }
            if (model.Step2HouseForSale != null)
            {
                return(View("HouseForSale/Step2", model));
            }
            if (model.Step2LandForSale != null)
            {
                return(View("LandForSale/Step2", model));
            }
            if (model.Step2RoomForRent != null)
            {
                return(View("RoomForRent/Step2", model));
            }
            return(RedirectToAction("Index"));
        }
Пример #12
0
        public async Task <IActionResult> Step2(Step2ViewModel model)
        {
            var site = await GetCurrentSiteAsync();

            if (site.SinglePageSignUp)
            {
                return(RedirectToAction("Index"));
            }
            if (!TempData.ContainsKey(TempStep1))
            {
                return(RedirectToAction("Step1"));
            }

            bool askAge    = false;
            bool askSchool = false;

            if (model.ProgramId.HasValue)
            {
                var program = await _siteService.GetProgramByIdAsync(model.ProgramId.Value);

                askAge    = program.AskAge;
                askSchool = program.AskSchool;
                if (program.AgeRequired && !model.Age.HasValue)
                {
                    ModelState.AddModelError("Age", "The Age field is required.");
                }
                if (program.SchoolRequired)
                {
                    if (!model.NewEnteredSchool && !model.SchoolId.HasValue)
                    {
                        ModelState.AddModelError("SchoolId", "The School field is required.");
                    }
                    else if (model.NewEnteredSchool &&
                             string.IsNullOrWhiteSpace(model.EnteredSchoolName))
                    {
                        ModelState.AddModelError("EnteredSchoolName", "The School Name field is required.");
                    }
                }
                if (model.NewEnteredSchool && !model.SchoolDistrictId.HasValue &&
                    ((program.AskSchool && !string.IsNullOrWhiteSpace(model.EnteredSchoolName)) ||
                     program.SchoolRequired))
                {
                    ModelState.AddModelError("SchoolDistrictId", "The School District field is required.");
                }
            }

            if (ModelState.IsValid)
            {
                if (!askAge)
                {
                    model.Age = null;
                }
                if (askSchool)
                {
                    if (model.NewEnteredSchool)
                    {
                        model.SchoolId = null;
                    }
                    else
                    {
                        model.EnteredSchoolName = null;
                    }
                }
                else
                {
                    model.SchoolId          = null;
                    model.EnteredSchoolName = null;
                }

                TempData[TempStep2] = Newtonsoft.Json.JsonConvert.SerializeObject(model);
                return(RedirectToAction("Step3"));
            }

            PageTitle = $"{site.Name} - Join Now!";

            var programList = await _siteService.GetProgramList();

            var programViewObject = _mapper.Map <List <ProgramViewModel> >(programList);

            model.ProgramList = new SelectList(programList.ToList(), "Id", "Name");
            model.ProgramJson = Newtonsoft.Json.JsonConvert.SerializeObject(programViewObject);
            model.ShowAge     = askAge;
            model.ShowSchool  = askSchool;

            var districtList = await _schoolService.GetDistrictsAsync();

            if (model.SchoolId.HasValue)
            {
                var schoolDetails = await _schoolService.GetSchoolDetailsAsync(model.SchoolId.Value);

                var typeList = await _schoolService.GetTypesAsync(schoolDetails.SchoolDisctrictId);

                model.SchoolDistrictList = new SelectList(districtList.ToList(), "Id", "Name",
                                                          schoolDetails.SchoolDisctrictId);
                model.SchoolTypeList = new SelectList(typeList.ToList(), "Id", "Name",
                                                      schoolDetails.SchoolTypeId);
                model.SchoolList = new SelectList(schoolDetails.Schools.ToList(), "Id", "Name");
            }
            else
            {
                model.SchoolDistrictList = new SelectList(districtList.ToList(), "Id", "Name");
                if (model.SchoolDistrictId.HasValue)
                {
                    var typeList = await _schoolService.GetTypesAsync(model.SchoolDistrictId);

                    model.SchoolTypeList = new SelectList(typeList.ToList(), "Id", "Name",
                                                          model.SchoolTypeId);
                    var schoolList = await _schoolService.GetSchoolsAsync(model.SchoolDistrictId,
                                                                          model.SchoolTypeId);

                    model.SchoolList = new SelectList(schoolList.ToList(), "Id", "Name");
                }
            }

            return(View(model));
        }
Пример #13
0
        public async Task <IActionResult> Step2(Step2ViewModel model)
        {
            var site = await GetCurrentSiteAsync();

            if (site.SinglePageSignUp)
            {
                return(RedirectToAction(nameof(Index)));
            }
            if (!TempData.ContainsKey(TempStep1))
            {
                return(RedirectToAction(nameof(Step1)));
            }

            bool askAge    = false;
            bool askSchool = false;

            if (model.ProgramId.HasValue)
            {
                var program = await _siteService.GetProgramByIdAsync(model.ProgramId.Value);

                askAge    = program.AskAge;
                askSchool = program.AskSchool;
                if (program.AgeRequired && !model.Age.HasValue)
                {
                    ModelState.AddModelError(DisplayNames.Age,
                                             _sharedLocalizer[ErrorMessages.Field,
                                                              _sharedLocalizer[DisplayNames.Age]]);
                }
                if (program.SchoolRequired && !model.SchoolId.HasValue && !model.SchoolNotListed &&
                    !model.IsHomeschooled)
                {
                    ModelState.AddModelError(nameof(model.SchoolId),
                                             _sharedLocalizer[ErrorMessages.Field,
                                                              _sharedLocalizer[DisplayNames.School]]);
                }
            }

            if (ModelState.IsValid)
            {
                if (!askAge)
                {
                    model.Age = null;
                }
                if (!askSchool)
                {
                    model.SchoolId        = null;
                    model.SchoolNotListed = false;
                    model.IsHomeschooled  = false;
                }
                else if (model.IsHomeschooled)
                {
                    model.SchoolId        = null;
                    model.SchoolNotListed = false;
                }
                else if (model.SchoolNotListed)
                {
                    model.SchoolId = null;
                }

                TempData[TempStep2] = JsonConvert.SerializeObject(model);
                return(RedirectToAction(nameof(Step3)));
            }

            PageTitle = _sharedLocalizer[Annotations.Title.JoinNow, site.Name];

            var programList = await _siteService.GetProgramList();

            var programViewObject = _mapper.Map <List <ProgramSettingsViewModel> >(programList);

            model.ProgramList = NameIdSelectList(programList.ToList());
            model.SchoolList  = NameIdSelectList(await _schoolService.GetSchoolsAsync());
            model.ProgramJson = JsonConvert.SerializeObject(programViewObject);
            model.ShowAge     = askAge;
            model.ShowSchool  = askSchool;

            return(View(model));
        }
 public IActionResult Step2(Step2ViewModel model)
 {
     return(StepResult(ModelState.IsValid));
 }
 public IActionResult Step2Post(Step2ViewModel vm)
 {
     HttpContext.Session.Set <Step2ViewModel>(STEP_2_SESSION_KEY, vm);
     return(RedirectToAction("LastStep"));
 }
Пример #16
0
 public Step2Page()
 {
     InitializeComponent();
     BindingContext = new Step2ViewModel(this.Navigation);
 }
Пример #17
0
        public ActionResult AddViewSight(Step2ViewModel model)
        {
            List <ViewSightViewModel> list = _listingService.AddViewSight(model);

            return(PartialView("Property/_ViewSightTablePartial", list));
        }
Пример #18
0
 public static void Map(Step2ViewModel source, Step3ViewModel target)
 {
     target.EmailAddress = source.EmailAddress;
 }