Beispiel #1
0
        public ActionResult Edit(int id)
        {
            GetSelectList();
            MusicInfo info = MusicBLL.GetList(p => p.ID == id).FirstOrDefault();

            return(View(info));
        }
Beispiel #2
0
        public ActionResult Delete(int id)
        {
            var info = MusicBLL.GetList(p => p.ID == id).FirstOrDefault();

            if (null == info)
            {
                return(Json(new APIJson(-1, "删除失败,参数有误")));
            }
            if (MusicBLL.Delete(info))
            {
                return(Json(new APIJson(0, "删除成功")));
            }
            return(Json(new APIJson(-1, "删除失败,请重试")));
        }
Beispiel #3
0
        private IQueryable <MusicInfo> GetListData()
        {
            var    list = MusicBLL.GetList(p => true);
            string Name = Function.GetRequestString("Name");

            if (!string.IsNullOrEmpty(Name))
            {
                list            = list.Where(a => a.Name.Contains(Name));
                ViewBag.TxtName = Name;
            }

            list = list.OrderBy(p => p.CategoryID).ThenBy(a => a.SortID).ThenBy(a => a.ID);
            return(list);
        }
Beispiel #4
0
        public ActionResult UpdateMD5()
        {
            var sresult = string.Empty;
            var list    = MusicBLL.GetList(a => true).ToList();

            foreach (var item in list)
            {
                var FileFullName = Server.MapPath(item.SRC);
                if (System.IO.File.Exists(FileFullName))
                {
                    item.MD5 = Md5Helper.GetMD5HashFromFile(FileFullName);
                    bool result = MusicBLL.Edit(item);
                    sresult += FileFullName + "|MD5=" + item.MD5 + "|Result=" + result;
                }
            }
            return(Content(sresult));
        }
Beispiel #5
0
        public ActionResult Edit(MusicInfo info)
        {
            MusicInfo infoExist = MusicBLL.GetList(p => p.ID == info.ID).FirstOrDefault();

            if (string.IsNullOrEmpty(info.Name))
            {
                return(Json(new APIJson("请填写名称")));
            }
            if (info.CategoryID <= 0)
            {
                return(Json(new APIJson("请选择分类")));
            }
            HttpPostedFileBase FileMain = Request.Files["FileMain"];

            if (null != FileMain)
            {
                info.SRC = "/Content/File/Music/" + Guid.NewGuid().ToString() + FileMain.FileName.Substring(FileMain.FileName.LastIndexOf("."));
                FileMain.SaveAs(Server.MapPath(info.SRC));
                infoExist.SRC = info.SRC;
                infoExist.MD5 = Md5Helper.GetMD5HashFromFile(Server.MapPath(info.SRC));
            }
            if (info.PlayTime <= 0)
            {
                info.PlayTime = 1;
            }

            infoExist.CategoryID = info.CategoryID;
            infoExist.Name       = info.Name;
            infoExist.SortID     = info.SortID;
            infoExist.Enable     = info.Enable;
            infoExist.PlayTime   = info.PlayTime;


            if (MusicBLL.Edit(infoExist))
            {
                return(Json(new APIJson(0, "提交成功")));
            }
            return(Json(new APIJson(-1, "提交失败,请重试")));
        }