public IHttpActionResult RateUser(RateUserRequestModel model)
        {
            var loggedUserId = this.User.Identity.GetUserId();

            if (loggedUserId == model.UserId)
            {
                return this.BadRequest("Users cannot rate themselves!");
            }

            this.users.RateUser(model);

            return this.Ok();
        }
        public void RateUser(RateUserRequestModel model)
        {
            var user = this.users
                .GetById(model.UserId);

            var rate = new UserRate()
            {
                Rate = int.Parse(model.Value)
            };

            user.Rates.Add(rate);
            this.users.SaveChanges();
        }
Ejemplo n.º 3
0
        public async Task <BaseRespond> RateUserAsync(string ratingId)
        {
            var request = new RateUserRequestModel()
            {
                RateeUserId = _rateeUserId,
                CallId      = _callId,
                RatingId    = ratingId,
            };

            var service  = new UserService();
            var responce = await service.RateUser(request);

            return(responce);
        }
Ejemplo n.º 4
0
        public async Task <BaseRespond> RateUser(RateUserRequestModel requestModel)
        {
            var responce = new BaseRespond();

            try
            {
                responce = await Post <BaseRespond, RateUserRequestModel>(RateUserAPI, requestModel);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }

            return(responce);
        }
Ejemplo n.º 5
0
        public IHttpActionResult Rate(RateUserRequestModel model)
        {
            if (!this.usersServices.IsUserExist(model.UserId))
            {
                return this.NotFound();
            }

            if (this.User.Identity.GetUserId() == model.UserId)
            {
                return BadRequest("You cannot rate your self!");
            }

            this.usersServices.Rate(model.UserId, model.Value);
            this.usersServices.UpdateRating(model.UserId);

            return this.Ok();
        }
Ejemplo n.º 6
0
        public IHttpActionResult Rate(RateUserRequestModel model)
        {
            if (!this.usersServices.IsUserExist(model.UserId))
            {
                return(this.NotFound());
            }

            if (this.User.Identity.GetUserId() == model.UserId)
            {
                return(BadRequest("You cannot rate your self!"));
            }

            this.usersServices.Rate(model.UserId, model.Value);
            this.usersServices.UpdateRating(model.UserId);

            return(this.Ok());
        }
        public IHttpActionResult Put(RateUserRequestModel model)
        {
            var user = this.data.Users.GetById(model.UserId);
            if (user == null)
            {
                return this.BadRequest(string.Format("No user with the provided id: {0}", model.UserId));
            }

            if (this.User.Identity.GetUserId() == model.UserId)
            {
                return this.BadRequest("Users cannot rate themselves!");
            }

            var rating = new Rating()
            {
                UserId = model.UserId,
                Value = model.Value
            };
            this.data.Ratings.Add(rating);
            this.data.SaveChanges();

            return this.Ok();
        }