public ActionResult StepThree(StepTwoViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("StepOne"));
            }

            var selectedSpecialtyId     = viewModel.SelectedSpecialty;
            var selectedMedicalCenterId = viewModel.SelectedMedicalCenter;

            var possibleAssignments = from a in db.DoctorAssignments
                                      where a.MedicalCenterId == selectedMedicalCenterId
                                      select a.DoctorId;

            var possibleSpecialDoctors = from d in db.Doctors
                                         where d.SpecialtyId == selectedSpecialtyId
                                         select d;

            var availableDoctors = possibleSpecialDoctors.Where(x => possibleAssignments.Contains(x.Id)).ToList();

            var nextViewModel = new StepThreeViewModel
            {
                SelectedMedicalCenter = selectedMedicalCenterId,
                Doctors = availableDoctors
            };

            return(View("StepThree", nextViewModel));
        }
        public ActionResult StepTwo(StepOneViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("StepOne"));
            }

            var selectedSpecialtyTypeId = viewModel.SelectedSpecialty;

            if (selectedSpecialtyTypeId == null)
            {
                return(RedirectToAction("StepOne"));
            }

            var possibleDoctors = from d in db.Doctors
                                  where d.SpecialtyId == selectedSpecialtyTypeId
                                  select d;

            var possibleAssignments = from a in db.DoctorAssignments
                                      join b in possibleDoctors on a.DoctorId equals b.Id
                                      select a;

            var possibleMedicalCenters = from a in db.MedicalCenters
                                         join b in possibleAssignments on a.Id equals b.MedicalCenterId
                                         select a;

            var nextViewModel = new StepTwoViewModel
            {
                SelectedSpecialty = selectedSpecialtyTypeId,
                MedicalCenters    = possibleMedicalCenters
            };

            return(View("StepTwo", nextViewModel));
        }
        public ActionResult StepTwoProcess(StepTwoViewModel model)
        {
            var viewModel = new StepTwoViewModel()
            {
                EthPrice  = _context.SetPrices.FirstOrDefault(x => x.Status == true).Price,
                MinEthBuy = _context.EthPurchaseRange.FirstOrDefault().Min,
                MaxEthBuy = _context.EthPurchaseRange.FirstOrDefault().Max
            };

            if (!ModelState.IsValid)
            {
                return(View("StepTwo", viewModel));
            }

            var email    = Session["UserEmail"].ToString().ToLower().Trim();
            var userInDb = _context.AspNetUsers.FirstOrDefault(u => u.RoleId == 2 && u.Email.ToLower().Trim() == email);

            if (userInDb == null)
            {
                ModelState.AddModelError("", "Something went wrong.");
                return(View("StepTwo", viewModel));
            }

            userInDb.WalletAddress   = model.WalletAddress;
            Session["WalletAddress"] = model.WalletAddress;

            _context.SaveChanges();

            return(RedirectToAction("StepFour"));
        }
Пример #4
0
        public void ShouldMainContainerBeHorizontalWhenDeviceOrientationIsInLandscapeMode()
        {
            //arrange
            viewModel = new StepTwoViewModel();

            //act
            DeviceManager.Orientation = Devices.Landscape.ToString();

            //assert
            viewModel.MainContainerOrientation.ShouldBe(StackOrientation.Horizontal);
        }
Пример #5
0
        public void ShouldMainContainerBeVerticalWhenDeviceOrientationIsInPortraitMode()
        {
            //arrange
            viewModel = new StepTwoViewModel();

            //act
            DeviceManager.Orientation = Devices.Portrait.ToString();

            //assert
            viewModel.MainContainerOrientation.ShouldBe(StackOrientation.Vertical);
        }
        public ActionResult StepTwo()
        {
            var viewModel = new StepTwoViewModel()
            {
                EthPrice  = _context.SetPrices.FirstOrDefault(x => x.Status == true).Price,
                MinEthBuy = _context.EthPurchaseRange.FirstOrDefault().Min,
                MaxEthBuy = _context.EthPurchaseRange.FirstOrDefault().Max
            };

            return(View(viewModel));
        }
Пример #7
0
        public void ShouldRefreshOrientationChangeTheOrientationOfTheMainContainer()
        {
            //arrange
            viewModel = new StepTwoViewModel();

            //act
            DeviceManager.Orientation = Devices.Portrait.ToString();

            //assert
            viewModel.MainContainerOrientation.ShouldBe(StackOrientation.Vertical);
            DeviceManager.Orientation = Devices.Landscape.ToString();
            viewModel.RefreshOrientation();
            viewModel.MainContainerOrientation.ShouldBe(StackOrientation.Horizontal);
        }
        public ActionResult stepTwo()
        {
            if (HttpContext.Session.GetInt32("articleId") != null)
            {
                int id = (int)HttpContext.Session.GetInt32("articleId");

                TempArticle tempArticle = dbContext.tempArticles.SingleOrDefault(ta => ta.Id == id);
                //// when we come back to step two after uploadin file
                //// error occur because type of file in TempArticle is String
                //// but in StepTwoViewModel it's IFormFile
                StepTwoViewModel model = _mapper.Map <TempArticle, StepTwoViewModel>(tempArticle);

                return(View(model));
            }
            return(View());
        }
Пример #9
0
        public void ShouldBackTutorialCommandSendUserToStepOnePage()
        {
            //arrange
            viewModel = new StepTwoViewModel();
            viewModel.NavigationService.SetRootPage(nameof(StepOnePage), new StepOneViewModel());
            viewModel.NavigationService.NavigateAsync(nameof(StepTwoPage), null, false);
            Page targetPage  = new StepOnePage();
            Page currentPage = viewModel.NavigationService.CurrentPage;

            //act
            Task.Run(async() =>
            {
                await viewModel.ExecuteBackTutorialCommandAsync();
            }).GetAwaiter().GetResult();
            currentPage = viewModel.NavigationService.CurrentPage;

            //assert
            NUnit.Framework.Assert.AreEqual(currentPage.Title, targetPage.Title);
        }
Пример #10
0
        public StepTwoPage(string calledFrom)
        {
            InitializeComponent();
            CalledFrom                = calledFrom;
            BindingContext            = viewModel = new StepTwoViewModel(calledFrom);
            viewModel.NoRegisterCall += () => showResult();
            MessagingCenter.Subscribe <StepTwoViewModel, string>(this, "StepTwo", (sender, arg) => {
                DisplayAlert(Translator.getText("Notice"), arg, "Ok");
            });



            lb_BackFunc();
            void lb_BackFunc()
            {
                try
                {
                    Back.GestureRecognizers.Add(new TapGestureRecognizer()
                    {
                        Command = new Command(async() =>
                        {
                            if (CalledFrom == Constants.RegisterCall)
                            {
                                Application.Current.MainPage = new StepOnePage(Constants.RegisterCall);
                            }
                            else
                            {
                                Navigation.PopModalAsync();
                            }
                        }
                                              )
                    });
                }
                catch (Exception ex) { Debug.WriteLine(ex); }
            }
        }
        public ActionResult stepTwo(StepTwoViewModel model)
        {
            string[] allowedFileTypes = { ".pdf", ".docx", ".html" };
            int      index            = 0;
            string   AllFiles         = "";
            string   AllDesignation   = "";
            bool     anyFileUploded   = false;

            if (model.Files == null)
            {
                return(View(model));
            }
            for (int i = 0; i < model.Files.Count(); i++)
            {
                var file = model.Files.ElementAt(i);
                if (file == null && i == 0)
                {
                    ModelState.AddModelError("", "First Main File Is A Required File");
                    continue;
                }

                if (file != null)
                {
                    string a = Path.GetExtension(file.FileName);
                    if (!allowedFileTypes.Contains(Path.GetExtension(file.FileName)))
                    {
                        ModelState.AddModelError("", "File Type Not Allowed");
                        continue;
                    }
                    var picUniqueName = string.Format("{0}-{1}{2}"
                                                      , Path.GetFileNameWithoutExtension(file.FileName)
                                                      , Guid.NewGuid().ToString("N")
                                                      , Path.GetExtension(file.FileName));
                    // Creating Destination path
                    string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "files");
                    string filePath      = Path.Combine(uploadsFolder, picUniqueName);
                    file.CopyTo(new FileStream(filePath, FileMode.Create));
                    AllFiles       += picUniqueName + "-;";
                    AllDesignation += model.Designation.ElementAt(index) + "-;";
                    index++;
                }
            }

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

            if (HttpContext.Session.GetInt32("articleId") != null)
            {
                int id = (int)HttpContext.Session.GetInt32("articleId");

                TempArticle article = dbContext.tempArticles.SingleOrDefault(ta => ta.Id == id);
                article.Files       = AllFiles;
                article.Designation = AllDesignation;

                dbContext.SaveChanges();
            }
            else
            {
                TempArticle article = new TempArticle()
                {
                    Files       = AllFiles,
                    Designation = AllDesignation,
                };
                dbContext.tempArticles.Add(article);
                dbContext.SaveChanges();
                HttpContext.Session.SetInt32("articleId", article.Id);
            }

            return(RedirectToAction("stepThree"));
        }