Exemplo n.º 1
0
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            var anonymousService = new AnonymousUserService();

            object routId;

            switch (httpContext.Request.HttpMethod)
            {
            case "POST":
                routId = httpContext.Request.Params["Id"];
                break;

            case "GET":
                routId = httpContext.Request.RequestContext.RouteData.Values["id"];
                break;

            default:
                routId = httpContext.Request.RequestContext.RouteData.Values["id"];
                break;
            }

            var annId = 0;

            if (routId != null)
            {
                annId = Convert.ToInt32(routId);
            }

            if (annId == 0 || !anonymousService.IsUserCanEditRealty(annId))
            {
                return(base.AuthorizeCore(httpContext));
            }
            return(true);
        }
Exemplo n.º 2
0
        //
        // GET: /Realty/Details/5

        public ActionResult Details(int?id, int?commentPage, RealtySortByParams sortModel = null)
        {
            ViewBag.SortModel = sortModel;
            if (!id.HasValue)
            {
                return(HttpNotFound());
            }

            var realty = _realtyRepository.Read(id.Value);

            if (realty == null)
            {
                return(HttpNotFound());
            }

            ViewBag.IsUserCanEditRealty = _anonymousUserService.IsUserCanEditRealty(realty.Id);
            realty.Views++;
            _realtyRepository.SaveIgnoreCurrency(realty);
            ViewBag.RealtyPhotos      = _photoRepository.ReadByRealty(realty.Id).ToArray();
            ViewBag.UpTimeHours       = int.Parse(ProjectConfiguration.Get.GetConfigValue("UpTimeRealty").ToString());
            ViewBag.SortModel         = sortModel;
            ViewBag.Categories        = _categoryRepository.Read();
            ViewBag.RealtyId          = realty.Id;
            ViewBag.IsIssetInBookmark = _bookmarkRepository.IsIsset(WebSecurity.CurrentUserId, realty.Id);
            ViewBag.Comments          = (realty.Comments != null && realty.Comments.Count > 0)
                ? realty.Comments.ToPagedList(commentPage ?? 1, ProjectConfiguration.Get.CommentsOnPage)
                : null;

            return(View(realty));
        }