public Lesson1 CreateUserAndStartLesson1(User user) { //next sanitize the data before further steps foreach (PropertyInfo propertyInfo in user.GetType().GetProperties()) { //get the value of the property object value = propertyInfo.GetValue(user, null); //do sanitization only for string if (value.GetType() == typeof(string)) { value = Regex.Replace(value.ToString(), @"[^A-Za-z0-9 _\.-{}]", ""); propertyInfo.SetValue(user, value, null); } } if (!user.IsValid()) { Lesson1 lesson1 = new Lesson1(); lesson1.AddError("Model is invalid!"); return(lesson1); } var lessonUser = CreateUser(user, LessonTypes.HowDoesYourCashFlow.ToString(CultureInfo.InvariantCulture)); var lesson1User = new Lesson1() { IndividualId = lessonUser.IndividualId, UserId = lessonUser.UserId, User = lessonUser }; return(lesson1User); }
public bool PostLesson1(Lesson1 lesson1) { if (lesson1.IsValid()) { lock (_lockObject) { SaltServiceAgent.PostLesson1(lesson1.ToDataContract()); return(true); } } else { lesson1.AddError("Lesson object is not valid"); return(false); } }