예제 #1
0
        public string MusicUpLoad()
        {
            try
            {
                HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; //获取传统context
                HttpRequestBase request = context.Request;                                       //定义传统request对象
                                                                                                 //string resultUrl = Upload(request.Files[0], "Music");
                SongList s = new SongList()
                {
                    WYID   = "",
                    S_Name = request.Form["sname"].ToString(),
                    S_Type = 1,
                    //先上传文件 在添加到歌手表
                    S_Url   = uri + Upload(request.Files[0], "Music"),
                    S_Cover = uri + Upload(request.Files[1], "MusicCover"),

                    //添加到数据库  这里直接接收返回的歌手id
                    S_Singer       = SongListService.AddSinger(UserInfoService.SelUserInfoByID(int.Parse(request.Form["uid"].ToString()))),
                    S_PlayCount    = 0,
                    S_CollectCount = 0,
                    S_UpTime       = DateTime.Now,
                    S_Lyric        = "",
                    S_Album        = 0
                };
                if (SongListService.AddSongList(s))
                {
                    return("添加成功");
                }
                return("添加失败");
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
예제 #2
0
        public string AddSongList([FromBody] object json)
        {
            bool f = true;
            //解析json信息
            JArray jar = (JArray)JsonConvert.DeserializeObject(json.ToString());

            for (int i = 0; i < jar.Count; i++)
            {
                JObject  j = JObject.Parse(jar[i].ToString());
                SongList s = new SongList()
                {
                    WYID   = j["S_Id"].ToString(),
                    S_Name = j["S_Name"].ToString(),
                    S_Type = 1,
                    //添加到数据库  这里直接接收返回的歌手id
                    S_Singer       = SongListService.AddSinger(j["S_Singer"].ToString()),
                    S_Url          = j["S_Url"].ToString(),
                    S_Cover        = j["S_Cover"].ToString(),
                    S_PlayCount    = 0,
                    S_CollectCount = 0,
                    S_UpTime       = DateTime.Now,
                    S_Lyric        = "",
                    S_Album        = 0,
                };
                if (!SongListService.AddSongList(s))
                {
                    f = false;
                }
            }
            if (f)
            {
                return("添加成功");
            }
            else
            {
                return("添加失败");
            }
        }