Ejemplo n.º 1
0
        public ActionResult LocationChange(LocationChangeModel _LocationChangeModel)
        {
            HomeIndexModel _HomeIndexModel = new HomeIndexModel();

            _HomeIndexModel.Locations = repository.GetLocations().ToList();
            var           currentUser    = idb.Users.Find(User.Identity.GetUserId());
            CultureHelper _CultureHelper = new CultureHelper(repository);

            //Check that user ID is a current location ID
            if (_HomeIndexModel.Locations.Any(l => l.id == _LocationChangeModel.LocationsId))
            {
                currentUser.LocationID = repository.GetLocations().Where(l => l.id == _LocationChangeModel.LocationsId).Select(o => o.id).FirstOrDefault();
                idb.SaveChanges();
                Location     _Location = repository.GetLocations().Where(l => l.id == currentUser.LocationID).FirstOrDefault();
                TimeZoneInfo TZone     = _CultureHelper.GetTimeZoneInfo(currentUser.LocationID);
                _HomeIndexModel.LocationsId         = _Location.id;
                _HomeIndexModel.CurrentUserLocation = _Location.Name;
            }
            else
            {
                TimeZoneInfo TZone     = _CultureHelper.GetTimeZoneInfo(currentUser.LocationID);
                Location     _Location = repository.GetLocations().Where(l => l.id == currentUser.LocationID).FirstOrDefault();
                _HomeIndexModel.LocationsId         = _Location.id;
                _HomeIndexModel.CurrentUserLocation = _Location.Name;
            }

            return(View("Index", _HomeIndexModel));
        }
Ejemplo n.º 2
0
        public ActionResult LocationChange()
        {
            LocationChangeModel _LocationChangeModel = new LocationChangeModel();

            _LocationChangeModel.Locations = repository.GetLocations().ToList();
            var      currentUser = idb.Users.Find(User.Identity.GetUserId());
            Location _Location   = repository.GetLocations().Where(l => l.id == currentUser.LocationID).FirstOrDefault();

            _LocationChangeModel.LocationsId         = _Location.id;
            _LocationChangeModel.CurrentUserLocation = _Location.Name;
            return(View(_LocationChangeModel));
        }