示例#1
0
        public dynamic CreatePref(dynamic userAccount, double? weight, string weightUnits)
        {
            var userPref = new UserPref();
            var userPrefs = userPref.All("UserAccountId=@0 and ValidTo is null", args: new object[] { userAccount.Id }).ToArray();
            foreach (var p in userPrefs) p.ValidTo = DateTime.UtcNow;
            userPref.Save(userPrefs.ToArray());

            return userPref.Insert(new { UserAccountId = userAccount.Id, Weight = weight, WeightUnits = weightUnits });
        }
示例#2
0
 /// <returns>All the user pref instances for the specified user account, from oldest to newest.</returns>
 public static IEnumerable<dynamic> UserPrefs(this object userAccount)
 {
     dynamic dynUserAccount = userAccount as dynamic;
     IEnumerable<dynamic> userPrefs = new UserPref().All("UserAccountId=@0", args: new object[] { dynUserAccount.Id });
     return userPrefs.OrderBy(userPref => userPref.ValidTo ?? DateTime.MaxValue);
 }