Example #1
0
        public static Response addToPlaylist(Request req)
        {
            int userid = tokenToUserId(req.token);

            if (userid != -1)
            {
                if (req.ctype == "json")
                {
                    JObject jObject = JObject.Parse(req.payload);
                    if (jObject.GetValue("Name") != null)
                    {
                        int mcid = DB_Tools.nameToMcid(jObject.GetValue("Name").ToString());
                        if (mcid != -1)
                        {
                            DB_Tools.addToPlaylist(mcid);
                            return(new Response(req, Status_Code.OK, AdditionalPayload: "Added to Playlist. "));
                        }
                        return(new Response(req, Status_Code.NOK, AdditionalPayload: "Invalid Song Name. Make sure it is spelled correctly. "));
                    }
                    return(new Response(req, Status_Code.NOK, AdditionalPayload: "Invalid Arguments. Please specify name. "));
                }
                return(new Response(req, Status_Code.NOK, AdditionalPayload: "Invalid Type. Please use Json. "));
            }
            return(new Response(req, Status_Code.NOK, AdditionalPayload: "Coulnd't verify connection. "));
        }
Example #2
0
        public static Response deleteFromLib(Request req)
        {
            int userid = tokenToUserId(req.token);

            if (userid != -1)
            {
                int mcid = DB_Tools.nameToMcid(req.loc.Substring(5).Trim());
                if (mcid != -1)
                {
                    if (DB_Tools.removeFromLib(userid, mcid))
                    {
                        return(new Response(req, Status_Code.NOK, AdditionalPayload: "Deleted. "));
                    }
                    return(new Response(req, Status_Code.NOK, AdditionalPayload: "Database error. "));
                }
                return(new Response(req, Status_Code.NOK, AdditionalPayload: "Couldn't find Song. "));
            }
            return(new Response(req, Status_Code.NOK, AdditionalPayload: "Couldn't verify Connection. "));
        }