Example #1
0
        public async Task <bool> CreateAsync(UserQuestionRestModel userQuestionRestModel)
        {
            var response = await _httpService.PostAsync <UserQuestionRestModel, object>(URL, userQuestionRestModel);

            if (!response.IsSuccess)
            {
                throw new ApplicationException(await response.GetBodyAsync());
            }

            return(response.IsSuccess);
        }
Example #2
0
        public async Task <UserQuestionRestModel> UpdateAsync(UserQuestionRestModel userQuestion)
        {
            var uri      = $"{URL}/{userQuestion.Id}";
            var response = await _httpService.UpdateAsync(uri, userQuestion);


            if (!response.IsSuccess)
            {
                throw new ApplicationException(await response.GetBodyAsync());
            }

            return(response.Response);
        }
Example #3
0
        public async Task <IActionResult> Post(UserQuestionRestModel contactUsFormRestModel)
        {
            var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var user   = await _userManager.FindByIdAsync(userId);

            var userEmail    = user.Email;
            var userQuestion = await _userQuestionService.CreateAsync(_mapper.Map <UserQuestion>(contactUsFormRestModel), userId, userEmail);

            if (userQuestion == null)
            {
                return(BadRequest());
            }

            return(Ok());
        }
Example #4
0
        public async Task <IActionResult> Put(int id, UserQuestionRestModel userQuestionRestModel)
        {
            if (userQuestionRestModel.Id.HasValue && id != userQuestionRestModel.Id)
            {
                return(BadRequest());
            }

            string userId       = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var    userQuestion = await _userQuestionService.UpdateAsync(_mapper.Map <UserQuestion>(userQuestionRestModel), userId);

            if (userQuestion == null)
            {
                return(NotFound());
            }

            return(Ok(_mapper.Map <UserQuestionRestModel>(userQuestion)));
        }