Пример #1
0
        public ActionResult Search(PropertySearch search, Guid? token)
        {
            if (!User.Identity.IsAuthenticated && token.HasValue)
            {
                var user = authAdapter.ValidateAuthToken(token.Value);
                if (user.StatusCode == 200)
                    CustomAuthentication.SetAuthCookie(user.Result.Username, user.Result.UserId, true);
                return Redirect("/property/search");
            }

            var result = this.propertyFacade.SearchForUserProperty(search);
            if (Request.IsAjaxRequest())
                return PartialView("SearchResults", result.Result);
            return View(result.Result);
        }
Пример #2
0
        public Status<PropertySearch> SearchForUserProperty(PropertySearch search)
        {
            var ident = CustomAuthentication.GetIdentity();
            if (!ident.IsAuthenticated)
                return Status.UnAuthorized<PropertySearch>();

            // if it is null create a new one
            if (search == null)
                search = new PropertySearch();
            if (search.Page < 1)
                search.Page = 1;
            if (search.ResultsPerPage < 5)
                search.ResultsPerPage = 25;
            if (string.IsNullOrEmpty(search.OrderBy))
                search.OrderBy = "CreateDate";

            using (var data = this.service.Get())
            {
                var result = data.Building.SearchUserBuildings(ident.UserId, search);
                search.Results = result;
                return Status.OK<PropertySearch>(search);
            }
        }