Exemplo n.º 1
0
        public ActionResult UserPreference()
        {
            var existingUser        = UserManager.FindById(User.Identity.GetUserId <long>());
            var preferenceViewModel = new PreferenceViewModel();

            preferenceViewModel._24_Hour_Front_Desk = existingUser._24_Hour_Front_Desk;
            preferenceViewModel.Airport_Suttle      = existingUser.Airport_Suttle;
            preferenceViewModel.Bar = existingUser.Bar;
            preferenceViewModel.Facilities_For_Disabled_Guest = existingUser.Facilities_For_Disabled_Guest;
            preferenceViewModel.Family_Rooms      = existingUser.Family_Rooms;
            preferenceViewModel.Fitness_Center    = existingUser.Fitness_Center;
            preferenceViewModel.Internet_Services = existingUser.Internet_Services;
            preferenceViewModel.Luggage_Storage   = existingUser.Luggage_Storage;
            preferenceViewModel.NewsNotifications = existingUser.NewsNotifications;
            preferenceViewModel.Parking           = existingUser.Parking;
            preferenceViewModel.Pets_Allowed      = existingUser.Pets_Allowed;

            preferenceViewModel.Pool = existingUser.Pool;
            if (!string.IsNullOrEmpty(existingUser.PreferedStarRating))
            {
                preferenceViewModel.PreferedStarRating = (PreferedStarRatingType)Enum.Parse(typeof(PreferedStarRatingType), existingUser.PreferedStarRating.ToString(), true);
            }
            preferenceViewModel.Restaurant = existingUser.Restaurant;
            if (!string.IsNullOrEmpty(existingUser.SmokingRoom))
            {
                preferenceViewModel.SmokingRoom = (PreferedSmokingRoomType)Enum.Parse(typeof(PreferedSmokingRoomType), existingUser.SmokingRoom, true);
            }
            preferenceViewModel.Spa_And_Wellness_Center = existingUser.Spa_And_Wellness_Center;
            preferenceViewModel.SpecialRequest          = existingUser.SpecialRequest;
            return(PartialView("_UserPreference", preferenceViewModel));
        }
Exemplo n.º 2
0
 public ActionResult Settings(PreferenceViewModel viewModel)
 {
     try
     {
         string        selectedNutrientName = Request.Form["nutrients"].ToString();
         var           user            = GetUser();
         var           dietPlan        = RetrievePlan(user);
         List <string> dietPreferences = new List <string>();
         List <string> healthLabels    = new List <string>();
         ResetNutrientValues();
         var selectedNutrient = db.Nutrients.SingleOrDefault(c => c.Name == selectedNutrientName);
         selectedNutrient.Min = viewModel.SelectedNutrient.Min;
         selectedNutrient.Max = viewModel.SelectedNutrient.Max;
         dietPreferences.AddRange(viewModel.SelectedPreferences.ToList());
         healthLabels.AddRange(viewModel.SelectedLabels.ToList());
         var preferencesInDb = db.DietPreferences.ToList();
         TogglePreferences(dietPreferences);
         ToggleHealthLabels(healthLabels);
         db.SaveChanges();
         return(RedirectToAction("Create"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 3
0
        public PreferenceView()
        {
            InitializeComponent();
            PreferenceViewModel vm = new PreferenceViewModel();

            this.DataContext = vm;
            if (vm.CloseAction == null)
            {
                vm.CloseAction = new Action(this.Close);
            }
        }
        // Util
        private PreferenceViewModel GetPreferenceModel(Preference preference)
        {
            var model = new PreferenceViewModel
            {
                Id          = preference.Id,
                UserId      = preference.UserId,
                ServiceId   = preference.ServiceId,
                ServiceName = preference.Service.Name
            };

            return(model);
        }
Exemplo n.º 5
0
        // GET: DietPlan/Settings
        public ActionResult Settings()
        {
            var user      = GetUser();
            var dietPlan  = RetrievePlan(user);
            var viewModel = new PreferenceViewModel
            {
                DietPreferences = db.DietPreferences.ToList(),
                Nutrients       = db.Nutrients.ToList(),
                HealthLabels    = db.HealthLabels.ToList()
            };

            return(View(viewModel));
        }
Exemplo n.º 6
0
        public ActionResult UserPreference(PreferenceViewModel preference)
        {
            try
            {
                JsonResult jsonData = null;

                if (ModelState.IsValid)
                {
                    var existingUser = UserManager.FindById(User.Identity.GetUserId <long>());
                    if (existingUser != null)
                    {
                        existingUser.SmokingRoom                   = preference.SmokingRoom.ToString();
                        existingUser.PreferedStarRating            = preference.PreferedStarRating.ToString();
                        existingUser.SpecialRequest                = preference.SpecialRequest;
                        existingUser.NewsNotifications             = preference.NewsNotifications;
                        existingUser.Facilities_For_Disabled_Guest = preference.Facilities_For_Disabled_Guest;
                        existingUser.Family_Rooms                  = preference.Family_Rooms;
                        existingUser.Fitness_Center                = preference.Fitness_Center;
                        existingUser.Internet_Services             = preference.Internet_Services;
                        existingUser.Pets_Allowed                  = preference.Pets_Allowed;
                        existingUser.Luggage_Storage               = preference.Luggage_Storage;
                        existingUser.Pool = preference.Pool;
                        existingUser._24_Hour_Front_Desk     = preference._24_Hour_Front_Desk;
                        existingUser.Restaurant              = preference.Restaurant;
                        existingUser.Spa_And_Wellness_Center = preference.Spa_And_Wellness_Center;
                        existingUser.Bar            = preference.Bar;
                        existingUser.Family_Rooms   = preference.Family_Rooms;
                        existingUser.Airport_Suttle = preference.Airport_Suttle;
                        existingUser.Parking        = preference.Parking;

                        UserManager.Update(existingUser);
                        jsonData = Json(new { status = true, message = " Preferences updated successfully ! " });
                    }
                    else
                    {
                        jsonData = Json(new { status = true, message = "Opps ! Something went wrong. Please try again." });
                    }
                }
                else
                {
                    jsonData = Json(new { status = false, message = GetErrorsFromModelState(ModelState.Values.ToList()) });
                }

                return(jsonData);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void SaveCommandTestValueToTrue()
        {
            PreferenceViewModel Pvm = new PreferenceViewModel();

            //Arrange
            Pvm.Preference.EnablePatientReusePrompt = true;

            //Act
            Pvm.SavePreferenceCommand.Execute(true);

            var actual   = Pvm.Settings.PatientPromptEnabled;
            var expected = true;

            //Assert
            Assert.AreEqual(actual, expected);
        }
        public PreferenceViewModel GetUserNotificationPreference(string action, string userID)
        {
            PreferenceViewModel model = new PreferenceViewModel();

            model.IsEmail = false;
            model.IsSms   = false;
            var userid = User.Identity.GetUserId();

            UserSetting settings = db.UserSettings.Where(x => x.UserId == userID && x.Action.ToLower() == action.ToLower()).FirstOrDefault();

            if (settings != null)
            {
                model.IsSms   = settings.IsSms;
                model.IsEmail = settings.IsEmail;
            }
            return(model);
        }
        public IActionResult addUserPreference(PreferenceViewModel userPreference, string salary, string divorced,
                                               string widowed, string bodyDealbreaker, string ethnicity,
                                               string EthnicityDealBreaker, string KidsDealBreaker,
                                               string DrinkingDealBreaker, string MusicDealBreaker,
                                               string DietDealBreaker, string PetsDealBreaker)
        {
            int minHeight = (userPreference.MinimumFeet * 12) + userPreference.MinimumInch;
            int maxHeight = (userPreference.MaxFeet * 12) + userPreference.MaxInch;

            User currentUser = getCurrentUserWithPreferences();

            currentUser.Preference.min_age   = userPreference.MinAge;
            currentUser.Preference.max_age   = userPreference.MaxAge;
            currentUser.Preference.MinSalary = salary;
            currentUser.Preference.MinHeight = minHeight;
            currentUser.Preference.MaxHeight = maxHeight;
            currentUser.Preference.Build     = userPreference.Build;
            currentUser.Preference.Ethnicity = ethnicity;
            currentUser.Preference.Kids      = userPreference.Kids;
            currentUser.Preference.Drinking  = userPreference.Drinking;
            currentUser.Preference.Music     = userPreference.Music;
            currentUser.Preference.Diet      = userPreference.Diet;
            currentUser.Preference.Pets      = userPreference.Pets;

            currentUser.Preference.BuildDealBreaker     = (bodyDealbreaker != null);
            currentUser.Preference.EthnicityDealBreaker = (EthnicityDealBreaker != null);
            currentUser.Preference.DivorcedDealBreaker  = (divorced != null);
            currentUser.Preference.WidowedDealBreaker   = (widowed != null);
            currentUser.Preference.KidsDealBreaker      = (KidsDealBreaker != null);
            currentUser.Preference.DrinkingDealBreaker  = (DrinkingDealBreaker != null);
            currentUser.Preference.MusicDealBreaker     = (MusicDealBreaker != null);
            currentUser.Preference.DietDealBreaker      = (DietDealBreaker == null);
            currentUser.Preference.PetsDealBreaker      = (PetsDealBreaker != null);

            _context.SaveChanges();

            int         currentUserId = getCurrentUserId();
            List <User> AllUsers      = _context.Users.Where(u => u.UserId != currentUserId).ToList();

            foreach (var person in AllUsers)
            {
                MatchingAlgorithm(currentUser.UserId, person.UserId);
            }
            return(RedirectToAction("Dashboard", "Match"));
        }
Exemplo n.º 10
0
        public ActionResult Update(PreferenceViewModel viewModel)
        {
            try
            {
                string        selectedNutrientName = Request.Form["nutrients"].ToString();
                var           user            = GetUser();
                var           dietPlan        = RetrievePlan(user);
                List <string> dietPreferences = new List <string>();
                List <string> healthLabels    = new List <string>();
                //Might wanna remove this below reset method
                ResetNutrientValues();
                if (viewModel.SelectedNutrient != null)
                {
                    var selectedNutrient = db.Nutrients.SingleOrDefault(c => c.Name == selectedNutrientName);
                    selectedNutrient.Min = viewModel.SelectedNutrient.Min;
                    selectedNutrient.Max = viewModel.SelectedNutrient.Max;
                }

                if (viewModel.DietPreferences != null)
                {
                    dietPreferences.AddRange(viewModel.SelectedPreferences.ToList());
                }

                if (viewModel.HealthLabels != null)
                {
                    healthLabels.AddRange(viewModel.SelectedLabels.ToList());
                }

                var preferencesInDb = db.DietPreferences.ToList();
                TogglePreferences(dietPreferences);
                ToggleHealthLabels(healthLabels);

                db.SaveChanges();
                return(RedirectToAction("Index", "AppUser"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 11
0
        public IActionResult addUserPreference(PreferenceViewModel userPreference, string salary, string divorced, string widowed, string bodyDealbreaker, string ethnicity, string EthnicityDealBreaker, string KidsDealBreaker, string DrinkingDealBreaker, string MarijuanaDealBreaker, string DietDealBreaker, string PetsDealBreaker)
        {
            int minHeight = (userPreference.MinimumFeet * 12) + userPreference.MinimumInch;
            int maxHeight = (userPreference.MaxFeet * 12) + userPreference.MaxInch;

            int? currentUserId = HttpContext.Session.GetInt32("currentUser");
            User currentUser   = _context.Users.Include(u => u.Preference).SingleOrDefault(findUser => findUser.UserId == currentUserId);

            Console.WriteLine("CURRENT USER:"******"Dashboard", "Match"));
        }
Exemplo n.º 12
0
        public PreferencePage()
        {
            InitializeComponent();

            BindingContext = viewModel = new PreferenceViewModel(this);
        }