public ActionResult VideoEdit(zhancaiw_video video) { int id; if (!int.TryParse(Request["id"], out id)) { return(Content(JsonReturn(Enum_ReturnStatus.失败, "参数错误", null))); } var model = db.zhancaiw_video.Where(c => c.videoID == id).FirstOrDefault(); if (model == null) { return(Content(JsonReturn(Enum_ReturnStatus.失败, "该数据不存在或已被删除", null))); } int sortid; if (!int.TryParse(Request["sortid"], out sortid)) { return(Content(JsonReturn(Enum_ReturnStatus.失败, "分类参数错误", null))); } string selval = Request["selval"]; if (string.IsNullOrEmpty(selval) || selval.IndexOf(',') == -1) { return(Content(JsonReturn(Enum_ReturnStatus.失败, "二级分类参数错误", null))); } string title = Request["title"]; if (string.IsNullOrEmpty(title)) { return(Content(JsonReturn(Enum_ReturnStatus.失败, "视频标题不能为空", null))); } string author = Request["author"]; if (string.IsNullOrEmpty(author)) { return(Content(JsonReturn(Enum_ReturnStatus.失败, "视频作者不能为空", null))); } string imgurl = Request["imgurl"]; string desc = Request["desc"]; if (string.IsNullOrEmpty(desc)) { return(Content(JsonReturn(Enum_ReturnStatus.失败, "视频描述不能为空", null))); } string url = Request["url"]; if (string.IsNullOrEmpty(url)) { return(Content(JsonReturn(Enum_ReturnStatus.失败, "视频播放地址不能为空", null))); } string sourceurl = Request["sourceurl"]; model.videoTitle = title; model.videoAuthor = author; if (!string.IsNullOrEmpty(imgurl)) { model.videoCover = imgurl; } model.videoDescripe = desc; model.videoUrl = url; model.videoSourceUrl = sourceurl; model.sortID = sortid; model.categoryID = selval; model.updateTime = DateTime.Now; db.SaveChanges(); return(Content(JsonReturn(Enum_ReturnStatus.成功, "更新成功", null))); }
public ActionResult VideoAdd(zhancaiw_video video) { int sortid; if (!int.TryParse(Request["sortid"], out sortid)) { return(Content(JsonReturn(Enum_ReturnStatus.失败, "分类参数错误", null))); } string selval = Request["selval"]; if (string.IsNullOrEmpty(selval) || selval.IndexOf(',') == -1) { return(Content(JsonReturn(Enum_ReturnStatus.失败, "二级分类参数错误", null))); } string title = Request["title"]; if (string.IsNullOrEmpty(title)) { return(Content(JsonReturn(Enum_ReturnStatus.失败, "视频标题不能为空", null))); } string author = Request["author"]; if (string.IsNullOrEmpty(author)) { return(Content(JsonReturn(Enum_ReturnStatus.失败, "视频作者不能为空", null))); } string imgurl = Request["imgurl"]; if (string.IsNullOrEmpty(imgurl)) { return(Content(JsonReturn(Enum_ReturnStatus.失败, "视频封面还没有上传", null))); } string desc = Request["desc"]; if (string.IsNullOrEmpty(desc)) { return(Content(JsonReturn(Enum_ReturnStatus.失败, "视频描述不能为空", null))); } string url = Request["url"]; if (string.IsNullOrEmpty(url)) { return(Content(JsonReturn(Enum_ReturnStatus.失败, "视频播放地址不能为空", null))); } string sourceurl = Request["sourceurl"]; zhancaiw_video model = new zhancaiw_video(); model.videoTitle = title; model.videoAuthor = author; model.videoCover = imgurl; model.videoDescripe = desc; model.videoUrl = url; model.videoSourceUrl = sourceurl; model.isRecommend = false; model.clickCount = 0; model.sortID = sortid; model.categoryID = selval; model.userID = UserInfo.userID; model.videoStatus = (int)Enum_VideoStatus.正常; model.addTime = DateTime.Now; db.zhancaiw_video.Add(model); db.SaveChanges(); return(Content(JsonReturn(Enum_ReturnStatus.成功, "添加成功", null))); }