public ActionResult GetByConditionPerPage(string UserID, string UserName, string RoleId, string DepartmentID) { UserDTO user = new UserDTO(); user.UserID = UserID; user.UserName = UserName; user.RoleId = RoleId; user.DepartmentID = DepartmentID; User condition = UserDTOMapper.MapFromDTO(user); IList list = ManagerFactory.UserManager.GetByCondition(condition); List <UserDTO> arr = new List <UserDTO>(); Dictionary <String, Object> result = new Dictionary <String, Object>(); int sIndex = this.Request["start"] == null ? 0 : int.Parse(this.Request["start"]); int pageSize = this.Request["limit"] == null ? list.Count : int.Parse(this.Request["limit"]); for (int i = 0; i < pageSize && (i + sIndex) < list.Count; i++) { arr.Add(UserDTOMapper.MapToDTO((User)list[i + sIndex])); } result.Add("rows", arr); result.Add("total", list.Count); return(this.Json(result)); }
public void Map_Correct_UserDTO() { var user = TestUtils.user; var result = new UserDTOMapper().MapFrom(user); Assert.IsInstanceOfType(result, typeof(UserDTO)); Assert.AreEqual(result.Id, user.Id); Assert.AreEqual(result.Name, user.Name); Assert.AreEqual(result.UserName, user.UserName); Assert.AreEqual(result.Password, user.PasswordHash); Assert.AreEqual(result.RoleId, user.RoleId); }
public ActionResult GetAll() { IList list = ManagerFactory.UserManager.GetAll(); IList <UserDTO> result = new List <UserDTO>(); foreach (User o in list) { result.Add(UserDTOMapper.MapToDTO(o)); } return(this.Json(result)); }
public ActionResult GetAllByDepartment(string id) { Department dep = ManagerFactory.DepartmentManager.GetDepartment(id); IList list = dep.UserList; IList <UserDTO> result = new List <UserDTO>(); foreach (User o in list) { result.Add(UserDTOMapper.MapToDTO(o)); } return(this.Json(result)); }
public ActionResult GetAllPerPage() { IList list = ManagerFactory.UserManager.GetAll(); List <UserDTO> arr = new List <UserDTO>(); Dictionary <String, Object> result = new Dictionary <String, Object>(); int sIndex = this.Request["start"] == null?0:int.Parse(this.Request["start"]); int pageSize = this.Request["limit"] == null ? list.Count : int.Parse(this.Request["limit"]); for (int i = 0; i < pageSize && (i + sIndex) < list.Count; i++) { arr.Add(UserDTOMapper.MapToDTO((User)list[i + sIndex])); } result.Add("rows", arr); result.Add("total", list.Count); return(this.Json(result)); }
public ActionResult GetUser(string userid) { var rdto = new ResultDTO(); User user = ManagerFactory.UserManager.GetUser(userid); UserDTO dto = UserDTOMapper.MapToDTO(user); if (user != null) { rdto.Message = "获取用户数据成功"; rdto.Result = true; rdto.Data = dto; } else { rdto.Message = "获取用户数据失败"; rdto.Result = false; } return(this.Json(rdto)); }
public ActionResult AddUser(UserDTO User) { var rdto = new ResultDTO(); Model.User u = UserDTOMapper.MapFromDTO(User); try { ManagerFactory.UserManager.SaveUser(u); rdto.Message = "添加成功"; rdto.Result = true; } catch (Exception e) { rdto.Message = "添加失败:" + e.Message; rdto.Result = false; } return(this.Json(rdto)); }
public ActionResult UpdateUser(UserDTO User) { var rdto = new ResultDTO(); Model.User u = UserDTOMapper.MapFromDTO(User); try { ManagerFactory.UserManager.UpdateUser(u); rdto.Message = "更新成功"; rdto.Result = true; } catch { rdto.Message = "更新失败"; rdto.Result = false; } return(this.Json(rdto)); }