private async Task Vote(bool up, InfoDTO info)
        {
            ServiceRepository serviceRepository = new ServiceRepository();

            page.upvote.IsTapEnabled   = false;
            page.downvote.IsTapEnabled = false;
            page.upvote.Opacity        = 0.4;
            page.downvote.Opacity      = 0.4;

            RateInfoPostDTO rip = new RateInfoPostDTO()
            {
                infoId = info.Id,
                userId = SessionManager.SessionID,
                score  = up
            };

            bool result = await serviceRepository.setVoteInfo(rip);

            if (result)
            {
                int factor = 1;
                if (!up)
                {
                    factor = -1;
                }
                page.likesCount.Text = (int.Parse(page.likesCount.Text) + factor).ToString();
            }

            page.upvote.IsTapEnabled   = true;
            page.downvote.IsTapEnabled = true;
            page.upvote.Opacity        = 1;
            page.downvote.Opacity      = 1;
        }
예제 #2
0
        public async Task <bool> setVoteInfo(RateInfoPostDTO postDTO)
        {
            bool?result = await fetchObject <bool?>(@"/info/rate/", "POST", postDTO);

            if (result == null)
            {
                return(false);
            }

            return((bool)result);
        }
예제 #3
0
        public IHttpActionResult Rate(RateInfoPostDTO reputationInfo)
        {
            bool success = true;

            if (ModelState.IsValid)
            {
                try
                {
                    ReputationInfoEntity repInfoDomain = _DTOAssempler.CreateReputationInfoEntity(reputationInfo);
                    IInfoServices        infoService   = ServiceFactory.getInfoServices();
                    success = infoService.Rate(repInfoDomain);
                }
                catch (Exception e)
                {
                    return(BadRequest(e.Message));
                }
            }
            else
            {
                return(BadRequest("Neispravni podaci"));
            }

            return(Ok(success));
        }