public JsonResult CreatePersonal(ResearchPlanAttachmentInfo info) { ResearchPlanInfo infoPlan = ResearchPlanBLL.GetList(a => a.ID == info.ResearchPlanID).FirstOrDefault(); var ifnoResearch = infoPlan.ResearchInfo.FirstOrDefault(); if (infoPlan.DateBegin.Date < DateTime.Now.Date) { return(Json(new APIJson(-1, "活动已过期"))); } if (infoPlan.TypeEnum != (int)SysEnum.ResearchPlanType.个人听课) { return(Json(new APIJson(-1, "数据有误,不是个人听评课数据"))); } //info.ResearchPlanID string SavePathRelative = SaveWechatImage(info.Name, infoPlan); info.Name = SavePathRelative.Substring(SavePathRelative.LastIndexOf("/") + 1); info.PathRelative = SavePathRelative.Substring(0, SavePathRelative.LastIndexOf("/") + 1); info.CreateDate = DateTime.Now; info.MineType = "images/jpg"; info.CreateUserID = ifnoResearch.lectureUserID; info.CreateUserName = CurrentUser.Name; info.TypeEnum = (int)SysEnum.ResearchPlanAttachmentType.教案; //info.Name = "课表" + Guid.NewGuid().ToString(); info.Memo = string.Empty; info.ShowName = "课表" + infoPlan.ResearchPlanAttachmentInfo.Count() + 1; if (ResearchPlanAttachmentBLL.Create(info).ID > 0) { //var datajson=infoPlan.ResearchPlanAttachmentInfo.Select(a => new { a.Name, FullPath = a.Name + a.PathRelative }); return(Json(new APIJson(0, "提交成功", GetImageJSON(infoPlan)))); } return(Json(new APIJson(-1, "提交失败,请重试"))); }
public ActionResult Delete(int ID) { ResearchPlanAttachmentInfo info = ResearchPlanAttachmentBLL.GetList(a => a.ID == ID).FirstOrDefault(); if (null == info) { return(Json(new APIJson("数据不存在"))); } var infoPlan = info.ResearchPlanInfo; if (infoPlan.Status != (int)SysEnum.ResearchPlanStatus.未开始) { return(Json(new APIJson(-1, "当前状态不能上传课表"))); } try { System.IO.File.Delete(Server.MapPath(info.PathRelative + info.Name)); } catch (Exception) {} if (ResearchPlanAttachmentBLL.Delete(info)) { return(Json(new APIJson(0, "删除成功", GetImageJSON(infoPlan)))); } return(Json(new APIJson("删除失败,请重试"))); }