예제 #1
0
        public ActionResult RemoveFromBookmarks(CategorySearchSortModel model)
        {
            var status = "success";

            try
            {
                switch (model.Category)
                {
                case CategorySearch.Announcement:
                    try
                    {
                        var announcementBookmark = _announcementBookmarkRepository.Read(WebSecurity.CurrentUserId, model.Id);
                        _announcementBookmarkRepository.Delete(announcementBookmark);
                    }
                    catch
                    {
                        status = "fail";
                    }
                    break;

                case CategorySearch.Realty:
                    try
                    {
                        var realtyBookmark = _realtyBookmarkRepository.Read(WebSecurity.CurrentUserId, model.Id);
                        _realtyBookmarkRepository.Delete(realtyBookmark);
                    }
                    catch
                    {
                        status = "fail";
                    }
                    break;

                case CategorySearch.Product:
                    try
                    {
                        var productBookmark = _productBookmarkRepository.Read(WebSecurity.CurrentUserId, model.Id);
                        _productBookmarkRepository.Delete(productBookmark);
                    }
                    catch
                    {
                        status = "fail";
                    }
                    break;

                default:
                    status = "fail";
                    break;
                }
            }
            catch
            {
                status = "fail";
            }

            return(Json(new { status = status }, "text/html"));
        }
예제 #2
0
        public ActionResult AddToBookmarks(CategorySearchSortModel model)
        {
            var status = "success";

            try
            {
                switch (model.Category)
                {
                case CategorySearch.Announcement:
                    _announcementBookmarkRepository.Save(new AnnouncementBookmark()
                    {
                        AnnouncementId = model.Id,
                        UserId         = WebSecurity.CurrentUserId
                    });
                    break;

                case CategorySearch.Realty:
                    _realtyBookmarkRepository.Save(new RealtyBookmark()
                    {
                        RealtyId = model.Id,
                        UserId   = WebSecurity.CurrentUserId
                    });
                    break;

                case CategorySearch.Product:
                    _productBookmarkRepository.Save(new ProductBookmark()
                    {
                        ProductId = model.Id,
                        UserId    = WebSecurity.CurrentUserId
                    });
                    break;

                default:
                    status = "fail";
                    break;
                }
            }
            catch
            {
                status = "fail";
            }

            return(Json(new { status = status }, "text/html"));
        }
예제 #3
0
        public ActionResult AddToBookmarks(CategorySearchSortModel model)
        {
            var status = "success";

            try
            {
                _bookmarkRepository.Save(new RealtyBookmark()
                {
                    RealtyId = model.Id,
                    UserId   = WebSecurity.CurrentUserId
                });
            }
            catch
            {
                status = "fail";
            }

            return(Json(new { status = status }, "text/html"));
        }