Beispiel #1
0
        public static object Add(string user, BirthData birthData)
        {
            string theBirthdayFormat = TheBirthdayFormat;
            Match  match             = Regex.Match(birthData.BirthdayFormat, theBirthdayFormat, RegexOptions.IgnoreCase);

            if (!match.Success && !birthData.TryFormatBirthday(theBirthdayFormat))
            {
                return(new { Message = "Sorry, I can't understand the birthday you supplied." });
            }

            if (UseFakeData)
            {
                return(FakeDataInterface.AddBirthData(user, birthData));
            }

            string returnMessage = DatabaseInterface.AddBirthData(user, birthData);

            if (Regex.IsMatch(returnMessage, "success", RegexOptions.IgnoreCase))
            {
                return(new { Message = returnMessage });
            }
            else
            {
                return(new { Message = "There was a problem adding that birthday. Here's what we know:\n\n" + returnMessage });
            }
        }
Beispiel #2
0
        public static IEnumerable <BirthData> GetBirthData(string user)
        {
            if (UseFakeData)
            {
                return(FakeDataInterface.GetBirthData(user));
            }

            return(DatabaseInterface.GetBirthData(user));
        }
Beispiel #3
0
        public static IEnumerable <BirthData> GetBirthData(string user, Dictionary <string, object> searchObject)
        {
            if (UseFakeData)
            {
                return(FakeDataInterface.GetBirthData(user, searchObject));
            }

            return(DatabaseInterface.GetBirthData(user, searchObject));
        }
Beispiel #4
0
        internal static void Delete(string user, Dictionary <string, object> searchObject)
        {
            if (UseFakeData)
            {
                FakeDataInterface.DeleteBirthData(user, searchObject);
            }

            DatabaseInterface.DeleteBirthData(user, searchObject);
        }
Beispiel #5
0
        internal static object Update(string user, BirthData birthData)
        {
            if (birthData == null)
            {
                return(new { Message = "I'm sorry, the server could not find the birth data in the object you passed in." });
            }

            string theBirthdayFormat = TheBirthdayFormat;
            string formatIn          = birthData.BirthdayFormat;

            if (formatIn == null)
            {
                formatIn = string.Empty;
            }
            Match match = Regex.Match(formatIn, theBirthdayFormat, RegexOptions.IgnoreCase);

            if (!match.Success && !birthData.TryFormatBirthday(theBirthdayFormat))
            {
                return(new { Message = "Sorry, I can't understand the birthday you supplied." });
            }

            if (UseFakeData)
            {
                return(FakeDataInterface.UpdateBirthData(user, birthData));
            }

            string returnMessage = DatabaseInterface.UpdateBirthData(user, birthData);

            if (Regex.IsMatch(returnMessage, "success", RegexOptions.IgnoreCase))
            {
                return(new { Message = returnMessage });
            }
            else
            {
                return(new { Message = "There was a problem adding that birthday. Here's what we know:\n\n" + returnMessage });
            }
        }