Example #1
0
        public async Task UpdateUserRating(Guid userId, Guid reportId, int rating)
        {
            var user = await _userRepo.GetById(userId);

            if (user == null)
            {
                this.Notify("Usuário não encontrado.");
                return;
            }

            //mesma validacao de user para o report

            var classf = await _repository.FindUserClassification(userId, reportId);

            if (classf == null)
            {
                classf = new ReportClassification()
                {
                    UserId   = userId,
                    ReportId = reportId,
                    Rating   = rating
                };

                await _repository.Add(classf);
            }
            else
            {
                classf.Rating = rating;
                await _repository.Update(classf);
            }
        }
        public async Task <ReportClassification> FindRatingByUserAndReport(Guid userId, Guid reportId)
        {
            var rating = await _repository.FindUserClassification(userId, reportId);

            if (rating == null)
            {
                rating = new ReportClassification()
                {
                    Rating   = 0,
                    UserId   = userId,
                    ReportId = reportId
                };

                await _repository.Add(rating);
            }

            return(rating);
        }