public ActionResult Edit(string id) { ViewBag.Perm = GetPermission(); MIS_Article_CategoryModel entity = m_BLL.GetById(id); return(View(entity)); }
public bool Create(ref ValidationErrors errors, MIS_Article_CategoryModel model) { try { MIS_Article_Category entity = m_Rep.GetById(model.Id); if (entity != null) { errors.Add(Suggestion.PrimaryRepeat); return(false); } entity = new MIS_Article_Category(); entity.BodyContent = model.BodyContent; entity.ChannelId = model.ChannelId; entity.CreateTime = model.CreateTime; entity.Enable = model.Enable; entity.Id = model.Id; entity.ImgUrl = model.ImgUrl; entity.Name = model.Name; entity.ParentId = model.ParentId; entity.Sort = model.Sort; if (m_Rep.Create(entity) == 1) { return(true); } errors.Add(Suggestion.InsertFail); return(false); } catch (Exception ex) { errors.Add(ex.Message); ExceptionHandler.WriteException(ex); return(false); } }
public JsonResult Create(MIS_Article_CategoryModel model) { model.Id = ResultHelper.NewId; // model.ChannelId = ResultHelper.NewId; model.CreateTime = ResultHelper.NowTime; if (model != null && ModelState.IsValid) { if (articleCategoryBLL.Create(ref errors, model)) { LogHandler.WriteServiceLog(GetCurrentUserId(), "Id" + model.Id + ",ChannelId" + model.Name, "成功", "创建", "IMIS_ArticleRepository"); return(Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed))); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetCurrentUserId(), "Id" + model.Id + ",ChannelId" + model.Name + "," + ErrorCol, "失败", "创建", "IMIS_ArticleRepository"); return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + ErrorCol))); } } else { return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + "\n" + ErrorInfo))); } }
public ActionResult Details(string id) { ViewBag.perm = GetPermission(); MIS_Article_CategoryModel model = m_BLL.GetById(id); return(View(model)); }
/// <summary> /// 校验Excel数据,这个方法一般用于重写校验逻辑 /// </summary> public virtual bool CheckImportData(string fileName, List <MIS_Article_CategoryModel> list, ref ValidationErrors errors) { var targetFile = new FileInfo(fileName); if (!targetFile.Exists) { errors.Add("导入的数据文件不存在"); return(false); } var excelFile = new ExcelQueryFactory(fileName); //对应列头 excelFile.AddMapping <MIS_Article_CategoryModel>(x => x.ChannelId, "ChannelId"); excelFile.AddMapping <MIS_Article_CategoryModel>(x => x.Name, "Name"); excelFile.AddMapping <MIS_Article_CategoryModel>(x => x.ParentId, "ParentId"); excelFile.AddMapping <MIS_Article_CategoryModel>(x => x.Sort, "Sort"); excelFile.AddMapping <MIS_Article_CategoryModel>(x => x.ImgUrl, "ImgUrl"); excelFile.AddMapping <MIS_Article_CategoryModel>(x => x.BodyContent, "BodyContent"); excelFile.AddMapping <MIS_Article_CategoryModel>(x => x.CreateTime, "CreateTime"); excelFile.AddMapping <MIS_Article_CategoryModel>(x => x.Enable, "Enable"); //SheetName var excelContent = excelFile.Worksheet <MIS_Article_CategoryModel>(0); int rowIndex = 1; //检查数据正确性 foreach (var row in excelContent) { var errorMessage = new StringBuilder(); var entity = new MIS_Article_CategoryModel(); entity.Id = row.Id; entity.ChannelId = row.ChannelId; entity.Name = row.Name; entity.ParentId = row.ParentId; entity.Sort = row.Sort; entity.ImgUrl = row.ImgUrl; entity.BodyContent = row.BodyContent; entity.CreateTime = row.CreateTime; entity.Enable = row.Enable; //============================================================================= if (errorMessage.Length > 0) { errors.Add(string.Format( "第 {0} 列发现错误:{1}{2}", rowIndex, errorMessage, "<br/>")); } list.Add(entity); rowIndex += 1; } if (errors.Count > 0) { return(false); } return(true); }
public ActionResult Create(string id) { MIS_Article_CategoryModel entity = new MIS_Article_CategoryModel() { ParentId = id, Enable = true }; return(View(entity)); }
public JsonResult Edit(MIS_Article_CategoryModel model) { if (model != null && ModelState.IsValid) { if (m_BLL.Edit(ref errors, model)) { LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",ChannelId" + model.Name, "成功", "修改", "MIS_Article_Category"); return(Json(JsonHandler.CreateMessage(1, Suggestion.EditSucceed))); } string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",ChannelId" + model.Name + "," + ErrorCol, "失败", "修改", "MIS_Article_Category"); return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail + ErrorCol))); } return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail))); }
public JsonResult Create(MIS_Article_CategoryModel model) { model.Id = ResultHelper.NewId; model.CreateTime = ResultHelper.NowTime; if (ModelState.IsValid) { if (m_BLL.Create(ref errors, model)) { LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",ChannelId" + model.Name, "成功", "创建", "MIS_Article_Category"); return(Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed))); } string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",ChannelId" + model.Name + "," + ErrorCol, "失败", "创建", "MIS_Article_Category"); return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + ErrorCol))); } return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail))); }
public MIS_Article_CategoryModel GetById(string id) { if (IsExist(id)) { MIS_Article_Category entity = m_Rep.GetById(id); MIS_Article_CategoryModel model = new MIS_Article_CategoryModel(); model.BodyContent = entity.BodyContent; model.ChannelId = entity.ChannelId ?? 0; model.CreateTime = entity.CreateTime ?? DateTime.Now; model.Enable = entity.Enable; model.Id = entity.Id; model.ImgUrl = entity.ImgUrl; model.Name = entity.Name; model.ParentId = entity.ParentId; model.Sort = entity.Sort ?? 0; return(model); } return(null); }
public virtual async Task <Tuple <ValidationErrors, bool> > CreateAsync(MIS_Article_CategoryModel model) { ValidationErrors errors = new ValidationErrors(); try { MIS_Article_Category entity = await m_Rep.GetByIdAsync(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return(new Tuple <ValidationErrors, bool>(errors, false)); } entity = new MIS_Article_Category(); entity.Id = model.Id; entity.ChannelId = model.ChannelId; entity.Name = model.Name; entity.ParentId = model.ParentId; entity.Sort = model.Sort; entity.ImgUrl = model.ImgUrl; entity.BodyContent = model.BodyContent; entity.CreateTime = model.CreateTime; entity.Enable = model.Enable; if (await m_Rep.CreateAsync(entity)) { return(new Tuple <ValidationErrors, bool>(errors, true)); } else { errors.Add(Resource.InsertFail); return(new Tuple <ValidationErrors, bool>(errors, false)); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(new Tuple <ValidationErrors, bool>(errors, false)); } }
public JsonResult Create(MIS_Article_CategoryModel model) { if (model != null && ModelState.IsValid) { if (m_BLL.Create(ref errors, model)) { LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id, "成功", "创建", "MIS_Article_Category"); return(Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed))); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + "," + ErrorCol, "失败", "创建", "MIS_Article_Category"); return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + ErrorCol))); } } else { return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail))); } }
/// <summary> /// 修改一个实体 /// </summary> /// <param name="errors">持久的错误信息</param> /// <param name="model">模型</param> /// <returns>是否成功</returns> public virtual bool Edit(ref ValidationErrors errors, MIS_Article_CategoryModel model) { try { MIS_Article_Category entity = m_Rep.GetById(model.Id); if (entity == null) { errors.add(Suggestion.Disable); return(false); } entity.Id = model.Id; entity.ChannelId = model.ChannelId; entity.Name = model.Name; entity.ParentId = model.ParentId; entity.Sort = model.Sort; entity.ImgUrl = model.ImgUrl; entity.BodyContent = model.BodyContent; entity.CreateTime = model.CreateTime; entity.Enable = model.Enable; if (m_Rep.Edit(entity)) { return(true); } else { errors.add(Suggestion.EditFail); return(false); } } catch (Exception ex) { errors.add(ex.Message); ExceptionHandler.WriteException(ex); //ExceptionHander.WriteException(ex); return(false); } }
public virtual MIS_Article_CategoryModel GetById(object id) { if (IsExists(id)) { MIS_Article_Category entity = m_Rep.GetById(id); MIS_Article_CategoryModel model = new MIS_Article_CategoryModel(); model.Id = entity.Id; model.ChannelId = entity.ChannelId; model.Name = entity.Name; model.ParentId = entity.ParentId; model.Sort = entity.Sort; model.ImgUrl = entity.ImgUrl; model.BodyContent = entity.BodyContent; model.CreateTime = entity.CreateTime; model.Enable = entity.Enable; return(model); } else { return(null); } }
public ActionResult Edit(string id) { MIS_Article_CategoryModel entity = m_BLL.GetById(id); return(View(entity)); }