public JsonResult GetPortalUser(string username, string password) { var httpClient = GetHttpClient(); var portalUser = PortalUserService.QueryPortalUserByUsernameByPassword(httpClient, username, password); if (portalUser == null) { return(Json("error", JsonRequestBehavior.AllowGet)); } if (portalUser.PortalUserRole == 0) { return(Json("error:Portaluserrole attribute of portal user object is null!", JsonRequestBehavior.AllowGet)); } List <PriceList> portalUserPriceLists; switch (portalUser.PortalUserRole) { case (int)PortalUserrole.Consumer: portalUserPriceLists = PriceListService.QueryPriceListByPortalUserRole(httpClient, portalUser.PortalUserRole); portalUser.PriceLists.AddRange(portalUserPriceLists); break; case (int)PortalUserrole.Vendor: if (portalUser.CustomerId == Guid.Empty) { return(Json("error:CustomerId attribute of portal user object is null!", JsonRequestBehavior.AllowGet)); } portalUserPriceLists = PriceListService.QueryPriceListByCustomer(GetHttpClient(), portalUser.CustomerId); if (portalUserPriceLists == null || portalUserPriceLists.Count == 0) { portalUserPriceLists = PriceListService.QueryPriceListByPortalUserRole(httpClient, (int)PortalUserrole.Consumer); } portalUser.PriceLists.AddRange(portalUserPriceLists); break; } var currentUser = new CurrentUser() { PortalUser = portalUser }; return(Json(currentUser, JsonRequestBehavior.AllowGet)); }