/// <summary> /// Create a new CollectionUser object /// </summary> /// <param name="collection">The collection</param> /// <param name="user">The user</param> /// <param name="access">Allow/deny access</param> /// <returns>The new CollectionUser object</returns> public static CollectionUser CreateNew(Collection collection, User user, bool access) { CollectionUser cu = new CollectionUser(); cu.CollectionId = collection.Id; cu.UserId = user.Id; cu.Access = access; cu.isNew = true; return cu; }
/// <summary> /// Create a new instance of Collection using data from database /// </summary> /// <param name="data">The data</param> /// <returns>A collection from data</returns> private static Collection FromData(Dictionary<string, object> data) { int id = Convert.ToInt32(data["id"]); Collection collection; if (cache.TryGetValue(id, out collection)) { return collection; } collection = new Collection(); collection.Id = id; collection.Name = Convert.ToString(data["name"]); collection.Path = Convert.ToString(data["path"]); collection.Public = Convert.ToInt32(data["public"]) == 1; collection.AutoAdd = Convert.ToInt32(data["autoadd"]) == 1; collection.CacheStatus = Convert.ToInt32(data["cachestatus"]); cache[collection.Id] = collection; return collection; }
/// <summary> /// Get an array of CollectionJson to be passed to client app /// </summary> /// <param name="collections">An array of collections</param> /// <returns>An array of CollectionJson</returns> public static CollectionJson[] ToJsonArray(Collection[] collections) { List<CollectionJson> objs = new List<CollectionJson>(); foreach (Collection collection in collections) { objs.Add(collection.ToJson()); } return objs.ToArray(); }
/// <summary> /// Create a new collection /// </summary> /// <param name="name">The collection name</param> /// <param name="path">The collection path</param> /// <param name="public_">Whether the collection is public</param> /// <param name="autoadd">Whether the collection uses auto add</param> /// <returns>A new collection</returns> public static Collection CreateNewCollection(string name, string path, bool public_, bool autoadd) { Collection newCollection = new Collection(); newCollection.Name = name; newCollection.Path = path; newCollection.Public = public_; newCollection.AutoAdd = autoadd; newCollection.CacheStatus = 1; return newCollection; }
/// <summary> /// Get all CollectionUser objects associated to a collection /// </summary> /// <param name="collection">The collection</param> /// <returns>An array of CollectionUser objects</returns> public static CollectionUser[] GetByCollection(Collection collection) { if (collection != null && collection.Id != -1) { return GetMultiple("`cid`=" + Database.Quote(collection.Id.ToString())); } return new CollectionUser[] { }; }
public static CollectionUser Get(Collection collection, User user) { CollectionUser[] cus = GetMultiple("`cid`=" + Database.Quote(collection.Id.ToString()) + " AND `uid`=" + Database.Quote(user.Id.ToString())); if (cus.Length > 0) { return cus[0]; } return null; }
public static Manga[] GetMangasWithFilter(Collection collection, string tag, string author, int type) { string where = "TRUE"; if (collection != null) { where += " AND `cid`=" + Database.Quote(collection.Id.ToString()); } if (!String.IsNullOrEmpty(tag)) { where += " AND `id` IN (SELECT `mid` FROM `mangatag` WHERE `tid` IN (SELECT `id` FROM `tag` WHERE `name`=" + Database.Quote(tag) + "))"; } if (!String.IsNullOrEmpty(author)) { where += " AND `id` IN (SELECT `mid` FROM `meta` WHERE `author`=" + Database.Quote(author) + ")"; } if (type != -1) { where += " AND `type`=" + Database.Quote(type.ToString()); } return GetMangas(where); }
public static Manga CreateNewManga(Collection collection, string path) { Manga newManga = new Manga(); newManga.ParentCollectionId = collection.Id; newManga._parentCollection = collection; newManga.MangaPath = path; newManga.MangaType = CheckMangaType(path); newManga.InnerRefreshContent(); newManga.View = newManga.Status = 0; newManga._meta = MangaMeta.CreateNewMeta(newManga); newManga.LeftToRight = false; string title = newManga.MangaPath.Substring(0, newManga.MangaPath.LastIndexOf(".")); title = title.Substring(title.LastIndexOf("\\") + 1); newManga.Title = title.Length > 100 ? title.Substring(0, 100) : title; return newManga; }