public ActionResult Create(AC_DepartmentModel model) { if (ModelState.IsValid) { ResultModel resultModel = new ResultModel(); if (model.ID == 0) { model.CreateBy = UserInfo.CurrentUserName; model.CreateDT = DateTime.Now; model.UpdateBy = model.CreateBy; model.UpdateDT = model.CreateDT; model.ParentID = 0; var result = _ACDepartmentService.AddAC_Department(model); resultModel.Messages = new List <string> { result.Data.ID > 0 ? "Add dept success" : "Add dept failed" }; } else { model.UpdateBy = UserInfo.CurrentUserName; model.UpdateDT = DateTime.Now; var result = _ACDepartmentService.UpdateAC_Department(model); resultModel.Messages = new List <string> { "Edit dept success" }; } return(Json(resultModel, JsonRequestBehavior.AllowGet)); } return(PartialView(model)); }
/// <summary> /// 添加部门 /// </summary> /// <param name="model">部门模型</param> public ResultModel AddAC_Department(AC_DepartmentModel model) { var result = new ResultModel { Data = _database.Db.AC_Department.Insert(model) }; return(result); }
/// <summary> /// 更新部门 /// </summary> /// <param name="model">部门模型</param> /// <returns>是否修改成功</returns> public ResultModel UpdateAC_Department(AC_DepartmentModel model) { var result = new ResultModel(); dynamic updateRecord = new SimpleRecord(); updateRecord.ID = model.ID; updateRecord.DeptName = model.DeptName; updateRecord.IsActive = model.IsActive; updateRecord.OrderNumber = model.OrderNumber; updateRecord.UpdateBy = model.UpdateBy; updateRecord.UpdateDT = model.UpdateDT; _database.Db.AC_Department.UpdateByID(updateRecord); return(result); }
/// <summary> /// 添加、编辑部门 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Create(int?id) { AC_DepartmentModel model = null; if (id.HasValue) { var result = _ACDepartmentService.GetAC_DepartmentById(id.Value); if (result.Data != null) { model = result.Data; } } if (model == null) { model = new AC_DepartmentModel(); model.IsActive = 1; } return(PartialView(model)); }
public void AC_DepartmentService_UpdateAC_Department_Test() { var entity = new AC_DepartmentModel { ID = 2, DeptName = "技术部22", IsActive = 1, OrderNumber = 0, ParentID = 0, CreateBy = "admin", CreateDT = DateTime.Now, UpdateBy = "admin", UpdateDT = DateTime.Now }; var resultModel = _acDepartmentService.UpdateAC_Department(entity); Assert.IsTrue(resultModel.Data == true); var resuleModelUpdated = _acDepartmentService.GetAC_DepartmentById(entity.ID); Assert.IsTrue(resuleModelUpdated.Data.DeptName == "技术部22"); }
public static AC_Department ToEntity(this AC_DepartmentModel model) { return(Mapper.Map <AC_Department>(model)); }