/// <summary> /// Initializes a new instance of the <see cref="MessagesViewModel" /> class. /// </summary> /// <param name="id">The identifier.</param> /// <param name="currentUser">The current user.</param> /// <param name="messageFunc">The message function.</param> /// <param name="groupId">The group identifier.</param> private MessagesViewModel(int id, User currentUser, MessageCollection.MessageFunc messageFunc, int?groupId = null) : base(TimeSpan.FromMinutes(5)) { this.Id = id; this.CurrentUser = currentUser.ThrowIfNull(nameof(currentUser)); this.MessageCollection = new MessageCollection(messageFunc.ThrowIfNull(nameof(messageFunc))); this.GroupId = groupId; this.LastRefresh = DateTimeOffset.UtcNow; }
/// <summary> /// Creates an instance, asynchronously. /// </summary> /// <param name="id">The identifier.</param> /// <param name="messageFunc">The message function.</param> /// <param name="groupId">The group identifier.</param> /// <returns> /// A created instance task. /// </returns> public static async Task <MessagesViewModel> CreateAsync(int id, MessageCollection.MessageFunc messageFunc, int?groupId = null) { User currentUser = await YammerService.Instance.GetCurrentUserAsync(); return(new MessagesViewModel(id, currentUser, messageFunc, groupId)); }