Ejemplo n.º 1
0
        public ActionResult SavePetPreferences(PetPreferencesModel model)
        {
            var _db = new SquareDanceDb();

            try
            {
                var userId         = User.Identity.GetUserId();
                var petPreferences = _db.ServiceAndRate.Find(userId);
                if (petPreferences != null)
                {
                    petPreferences.BoardingSmallDog     = model.BoardingSmallDog;
                    petPreferences.BoardingMediumDog    = model.BoardingMediumDog;
                    petPreferences.BoardingLargeDog     = model.BoardingLargeDog;
                    petPreferences.BoardingGiantDog     = model.BoardingGiantDog;
                    petPreferences.BoardingUnderOne     = model.BoardingUnderOne;
                    petPreferences.HostDifferentFamily  = model.HostDifferentFamily;
                    petPreferences.HostMaleNotNeutered  = model.HostMaleNotNeutered;
                    petPreferences.HostFemaleNotSpayed  = model.HostFemaleNotSpayed;
                    petPreferences.HostNeedCrateTrained = model.HostNeedCrateTrained;
                    petPreferences.HouseSmallDog        = model.HouseSmallDog;
                    petPreferences.HouseMediumDog       = model.HouseMediumDog;
                    petPreferences.HouseLargeDog        = model.HouseLargeDog;
                    petPreferences.HouseGiantDog        = model.HouseGiantDog;
                    petPreferences.HouseUnderOne        = model.HouseUnderOne;
                    _db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                logger.Error("An error occurred while SavePetPreferences. Error: " + e);
            }
            finally
            {
                _db.Dispose();
            }
            return(RedirectToAction("UserProfile", "Account"));
        }
Ejemplo n.º 2
0
        public ActionResult PetPreferences()
        {
            var model = new PetPreferencesModel();
            var _db   = new SquareDanceDb();

            try
            {
                var userId         = User.Identity.GetUserId();
                var petPreferences = _db.ServiceAndRate.Find(userId);
                if (petPreferences != null)
                {
                    model = new PetPreferencesModel(petPreferences);
                }
            }
            catch (Exception e)
            {
                logger.Error("An error occurred while PetPreferences. Error: " + e);
            }
            finally
            {
                _db.Dispose();
            }
            return(View(model));
        }