コード例 #1
0
        public ActionResult SignupNow(string emailAddr, string firstName, string lastName, string chkAgree)
        {
            // Test Business Rules again before adding to the store
            var validEmail     = Regex.IsMatch(emailAddr, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$");
            var validFirstName = (firstName.Length >= 3 && firstName.Length <= 80);
            var validLastName  = (lastName.Length >= 3 && lastName.Length <= 80);
            var validAgree     = (chkAgree == "on");

            if (validEmail && validFirstName && validLastName && validAgree)
            {
                var tst = CacheRepo.AddUser(HttpContext.Cache, emailAddr, firstName, lastName);
                if (tst["message"].ReadAs <string>() == "Email already exists")
                {
                    return(View("Confirmation", false));
                }
                else
                {
                    return(View("Confirmation", true));
                }
            }
            else
            {
                throw new Exception("Business Rule Failure");
            }
        }
コード例 #2
0
        public object GetWeather(int locationId)
        {
            string responseString = CacheRepo.GetResponseFromLastFiveMinutesByLocationId(locationId);

            if (string.IsNullOrEmpty(responseString))
            {
                var location = LocationRepo.GetLocationById(locationId);

                var client  = new RestClient("http://api.openweathermap.org/data/2.5/");
                var request = new RestRequest("forecast?zip=" + location.Zipcode + ",us&appid=" + APPID + "&units=imperial");

                var response = client.Execute(request);
                responseString = response.Content;
                CacheRepo.SaveResponse(responseString, locationId);
            }
            var responseObject = JsonConvert.DeserializeObject <object>(responseString);

            return(responseObject);
        }
コード例 #3
0
        public JsonValue GetUser(string email)
        {
            var ret = CacheRepo.GetUser(HttpContext.Current.Cache, email);

            return(ret);
        }
コード例 #4
0
        public JsonValue GetAllUsers()
        {
            var ret = CacheRepo.GetAllUsers(HttpContext.Current.Cache);

            return(ret);
        }