Example #1
0
        public async Task <ProfessionalQuestionsModel> GetProfessionalQuestions(Guid userId)
        {
            //Get user/professionals professional data for questions
            var data = await _userRepository.GetProfessionalFormById(userId);

            //Get selected services by user
            var userServices = await _userRepository.GetUserServices(userId);

            //Get list of services
            var categories = await _categoryRepository.GetAllAsync();

            //map with service model
            List <UserServices> serviceList = new List <UserServices>();

            foreach (var userService in userServices)
            {
                serviceList.Add(new UserServices
                {
                    Id   = userService,
                    Name = categories.Where(s => s.Id == userService).Select(s => s.Name).FirstOrDefault()
                });
            }

            ProfessionalQuestionsModel questionsModel = new ProfessionalQuestionsModel
            {
                Questions    = JsonConvert.DeserializeObject <List <DataContracts.ViewModels.User.Question> >(data.Questions),
                UserServices = serviceList
            };

            return(questionsModel);
        }
Example #2
0
        public async Task <bool> UpdateProfessionalQuestions(Guid userId, ProfessionalQuestionsModel model)
        {
            var question = JsonConvert.SerializeObject(model.Questions);

            foreach (var service in model.UserServices)
            {
                await _userRepository.AddUserServices(userId, service.Id);
            }

            return(await _userRepository.UpdateProfessionalQuestions(userId, question));
        }
Example #3
0
        public async Task <ActionResult> UpdateQuestions([FromBody] ProfessionalQuestionsModel model)
        {
            try
            {
                var res = await _userManager.UpdateProfessionalQuestions(currentUsers.Id, model);

                return(Ok(new ResponseViewModel <bool>
                {
                    Data = res,
                    Message = res ? TazzerCleanConstants.SavedSuccess : TazzerCleanConstants.GeneralError
                }));
            }
            catch (Exception ex)
            {
                _logger.LogError("An error has been thrown in UserController:UpdateQuestions", ex);
                return(BadRequest());
            }
        }