private protected ContentShare(Api api, ContentShareModel model) { _api = api; Id = model.Id; Name = model.Name; ContentType = model.ContentType.ToApiRepresentedEnum <ContentShareType>() .Expect(() => new BadApiStateException($"ContentShare.ContentType was an unexpected value: {model.ContentType}")); CreatedAt = model.CreatedAt; UpdatedAt = model.UpdatedAt; UserId = model.UserId; CourseId = model.SourceCourse?.Id; ReadState = (model.ReadState ?? "") == "read"; ContentExportId = model.ContentExport?.Id; }
internal static ContentShare NewContentShare(Api api, ContentShareModel model) { if (model.Sender != null) { return(new ContentShareWithSender(api, model)); } else if (model.Receivers != null) { return(new ContentShareWithReceivers(api, model)); } else { throw new BadApiStateException("ContentShare.Sender & ContentShare.Receivers were both null."); } }
internal ContentShareWithReceivers(Api api, ContentShareModel model) : base(api, model) { Debug.Assert(model.Receivers != null, "model.Receivers != null"); Receivers = model.Receivers.SelectNotNull(r => new ShortUser(api, r)); }
internal ContentShareWithSender(Api api, ContentShareModel model) : base(api, model) { Debug.Assert(model.Sender != null, "model.Sender != null"); Sender = new ShortUser(api, model.Sender); }