Exemple #1
0
        public async Task <string> SubmitRating(RatingRequestModel ratingRequestModel)
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                try
                {
                    var uri     = new Uri("http://104.238.81.169:4080/FitnessApp/manageservices/v1/members/addTReview");
                    var json    = JsonConvert.SerializeObject(ratingRequestModel);
                    var content = new StringContent(json, Encoding.UTF8, "application/json");

                    HttpResponseMessage response = null;

                    response = await client.PostAsync(uri, content);

                    if (response.IsSuccessStatusCode)
                    {
                        return("Success");
                    }
                    else
                    {
                        return("Failure");
                    }
                }
                catch (Exception ex)
                {
                    return("Failure");
                }
            }
            else
            {
                return("Failure");
            }
        }
        public IHttpActionResult RateUser(RatingRequestModel model)
        {
            if (model == null || !this.ModelState.IsValid)
            {
                return this.BadRequest(InvalidModelMessage);
            }

            this.users.Rate(model.UserId, model.Value);
            return this.Ok();
        }
        public IHttpActionResult Put(RatingRequestModel rating)
        {
            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            var value = this.ratings.Rate(rating.PetId, User.Identity.GetUserId(), rating.Value);

            return this.Created(this.Url.ToString(), value);
        }
        public IHttpActionResult Rate(RatingRequestModel model)
        {
            if (this.User.Identity.GetUserId() == model.UserId)
            {
                return this.BadRequest("You cannot give rating to yourself!");
            }

            var rating = Mapper.Map<Rating>(model);
            this.users.Rate(rating);
            return this.Ok();
        }
Exemple #5
0
        public IHttpActionResult Rate(RatingRequestModel model)
        {
            if (this.User.Identity.GetUserId() == model.UserId)
            {
                return(this.BadRequest("You cannot give rating to yourself!"));
            }

            var rating = Mapper.Map <Rating>(model);

            this.users.Rate(rating);
            return(this.Ok());
        }
        public async Task <IActionResult> GetMyRating(RatingRequestModel ratingRequest)
        {
            var user   = await _userManager.FindByNameAsync(User.Identity.Name);;
            var rating = _appDbContext.Ratings
                         .FirstOrDefault(rating => rating.UserId == user.Id && rating.FunficId == ratingRequest.Id);

            if (rating == null)
            {
                return(StatusCode(200, new { rating = 0 }));
            }

            return(StatusCode(200, new { rating = rating.StarsCount }));
        }
        public async Task <IActionResult> GetComments(RatingRequestModel commentsRequest)
        {
            var comments = _appDbContext.Comments
                           .Where(comment => comment.FunficId == commentsRequest.Id)
                           .Join(_appDbContext.Users,
                                 c => c.UserId,
                                 u => u.Id,
                                 (c, u) => new
            {
                author    = u.UserName,
                text      = c.Text,
                createdAt = c.Date
            });

            return(StatusCode(200, comments));
        }
        public IHttpActionResult Put(RatingRequestModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            var userId = this.User.Identity.GetUserId();

            if (model.UserId == userId)
            {
                return(this.BadRequest("You cannot rate yourself!"));
            }

            var rate = Mapper.Map <Rating>(model);

            this.users.RateUser(rate, userId);

            return(this.Ok());
        }
        async void Done_Clicked(object sender, System.EventArgs e)
        {
            RatingView.IsVisible = false;

            LoadingText.Text = "Submitting...";

            RatingRequestModel ratingRequestModel = new RatingRequestModel(RatingIndex * 2, CommentText.Text, TraineeEmailId, TrainerEmailId);

            String message = await App.TodoManager.SubmitRating(ratingRequestModel);

            if (message == "Success")
            {
                await DisplayAlert("Alert", "Rating submitted successfully.", "Ok");
            }
            else
            {
                await DisplayAlert("Alert", "Something went wrong. Please try again.", "Ok");
            }

            OpaqueView.IsVisible = false;
        }
Exemple #10
0
 public Task <String> SubmitRating(RatingRequestModel ratingRequestModel)
 {
     return(restService.SubmitRating(ratingRequestModel));
 }
Exemple #11
0
 public Task <string> SubmitRating(RatingRequestModel ratingRequestModel)
 {
     throw new NotImplementedException();
 }
        private async Task MakeRating(object dynamicObject)
        {
            try
            {
                RatingRequestModel myRequest = (RatingRequestModel)dynamicObject;

                int userID    = (await _userService.Get <List <UserDTO> >(new UserSearchRequest {
                    UserName = APIService.Username
                })).FirstOrDefault(_ => _.UserName == APIService.Username).Id;
                var newRating = new RatingInsertRequest
                {
                    HotelRating     = myRequest.HotelRating,
                    TransportRating = myRequest.TransportRating,
                    RatingDate      = DateTime.Now,
                    ReservationId   = myRequest.ReservationId,
                    UserId          = userID
                };
                var reservation = await _reservationService.GetById <ReservationDTO>(myRequest.ReservationId);

                if (reservation.StartTripDate != default(DateTime))
                {
                    if (reservation.StartTripDate > DateTime.Now)
                    {
                        await Application.Current.MainPage.DisplayAlert("Info", "Trip has not happend yet", "OK");

                        return;
                    }
                }


                var tOffer = await _tOfferService.GetById <TransportOfferDTO>(reservation.TransportOfferId);

                var hOffer = await _hOfferService.GetById <HotelOfferDTO>(reservation.HotelOfferId);

                var hotel = await _hotelService.GetById <HotelDTO>(hOffer.HotelId);

                var tCompany = await _tCompanyService.GetById <TransportCompanyDTO>(tOffer.TransportCompanyId);

                bool sameRatings = (await _ratingService.Get <List <RatingDTO> >(new RatingSearchRequest {
                })).Any(_ => _.HotelId == hotel.Id && tCompany.Id == _.TransportCompanyId &&
                        _.UserId == userID);
                if (sameRatings)
                {
                    await Application.Current.MainPage.DisplayAlert("Info", "You can't rate same reservation again", "OK");

                    return;
                }

                newRating.TransportCompanyId = tCompany.Id;
                newRating.HotelId            = hotel.Id;


                var res = await _ratingService.Insert <RatingDTO>(newRating);

                if (res != null)
                {
                    var allHotelOffers = await _hOfferService.Get <List <HotelOfferDTO> >(new HotelOfferSearchRequest { HotelId = hotel.Id });

                    var allTransportOffers = await _tCompanyService.Get <List <TransportOfferDTO> >(new TransportOfferSearchRequest { TransportCompanyId = tCompany.Id });

                    float averageHotelRating     = (float)(await _ratingService.Get <List <RatingDTO> >(new RatingSearchRequest {
                        HotelId = hotel.Id
                    })).Average(_ => _.HotelRating);
                    float averageTransportRating = (float)(await _ratingService.Get <List <RatingDTO> >(new RatingSearchRequest {
                        TransportCompanyId = tCompany.Id
                    })).Average(_ => _.TransportRating);

                    var hotelUpdateRequest = new HotelInsertRequest
                    {
                        HotelAddress = hotel.HotelAddress,
                        HotelName    = hotel.HotelName,
                        CityId       = hotel.CityId,
                        TotalVisits  = hotel.TotalVisits,
                        Rating       = averageHotelRating,
                        Picture      = hotel.Picture
                    };
                    var transportUpdateRequest = new TransportCompanyInsertRequest
                    {
                        TransportCompanyName = tCompany.TransportCompanyName,
                        IsActive             = tCompany.IsActive,
                        Picture         = tCompany.Picture,
                        TransportTypeId = tCompany.TransportTypeId
                    };
                    var hotelResult = await _hotelService.Update <HotelDTO>(hotel.Id, hotelUpdateRequest);

                    var transportResult = await _tCompanyService.Update <TransportCompanyDTO>(tCompany.Id, transportUpdateRequest);

                    if (hotelResult != null && transportResult != null)
                    {
                        await Application.Current.MainPage.DisplayAlert("INFO", "Successufully added Rating!", "OK");
                    }
                    else
                    {
                        await Application.Current.MainPage.DisplayAlert("INFO", "Error adding Rating!", "OK");
                    }
                }
            }
            catch (Exception)
            {
                await Application.Current.MainPage.DisplayAlert("Error", "Make sure that all inputs are correct", "OK");
            }
        }