public WebResponse DoLogin(HttpRequest request, WebRequest webRequest) { user requestUser = webRequest.user; if (null == requestUser) { return(WebResponse.failed("Invalid Login")); } user AuthUser = userService.GetUserByUsernameAndPassword(requestUser.username, requestUser.password); if (AuthUser != null) { WebResponse response = WebResponse.success(); user finalUser = (user)ObjectUtil.CopyObjectIgnore(AuthUser, "posts", "password", "institution"); response.user = finalUser; bool updateSession = sessionService.putUser(webRequest.requestId, finalUser); if (updateSession) { List <division> divisionList = divisionService.GetByInsitutionId(finalUser.institution_id); List <division> resultList = new List <division>(); //avoid circular foreach (division Div in divisionList) { resultList.Add((division)ObjectUtil.CopyObjectIgnore(Div, "institution", "sections")); } response.divisions = resultList; return(response); } } return(WebResponse.failed()); }