public async Task <ActionResult <Review> > AddReplyToComment(AddReplyToComment model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var row = await _ApplicationDbContext.Reviews.Where(x => x.Id == model.ReviewId).FirstOrDefaultAsync();

                if (row != null)
                {
                    row.ReplyByTheOwner = model.ReviewReply;
                }

                var result = _ApplicationDbContext.SaveChanges();

                return(Ok(model));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, nameof(New));
                throw;
            }
        }
Beispiel #2
0
        async Task ExecuteSaveReplyCommand(object objReviewId)
        {
            IsBusy = true;

            try
            {
                Guid   ReviewId       = Guid.Parse(objReviewId.ToString());
                Review ReviewToUpdate = Restaurant.Reviews.Where(x => x.Id == ReviewId).FirstOrDefault();

                if (string.IsNullOrWhiteSpace(ReviewToUpdate.ReplyByTheOwner) == true)
                {
                    await Application.Current.MainPage.DisplayAlert("Validation", "The Reply field is empty", "Ok");
                }
                else
                {
                    AddReplyToComment data = new AddReplyToComment()
                    {
                        ReviewId    = ReviewId,
                        ReviewReply = ReviewToUpdate.ReplyByTheOwner
                    };



                    var res = await Services.APIComm.CallPostAsync(data, "Reviews/AddReplyToComment", true);

                    if (res.Success == true)
                    {
                        FrameCreateReview_Isvisible = false;
                        await LoadData(Restaurant.Id);
                    }
                    else
                    {
                        await Application.Current.MainPage.DisplayAlert("Error", string.Join(Environment.NewLine, res.ContentString_responJsonText), "Ok");
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok");
            }
            finally
            {
                IsBusy = false;
            }
        }