예제 #1
0
        public ActionResult MapInternalUser(ViewModel.InternalUserViewModel user)
        {
            GenericAjaxResponse <bool> response = new GenericAjaxResponse <bool>();

            try
            {
                if (ModelState.IsValid)
                {
                    Core.DTO.InternalUserInfo userInfo = new Core.DTO.InternalUserInfo();
                    userInfo.ActiveHealthId = user.ActiveHealthId;
                    userInfo.TableauId      = user.TableauId;
                    response = _restClient.MapInternalUser(userInfo);
                    if (response == null)
                    {
                        response         = new GenericAjaxResponse <bool>();
                        response.Success = false;
                        response.Errors.Add("Could not process your request.");
                    }
                    else
                    {
                        response.Success = response.Data;
                    }
                }
                else
                {
                    foreach (var modelKey in ModelState.Keys)
                    {
                        response.Errors.AddRange(ModelState[modelKey].Errors.Select(err => err.ErrorMessage));
                    }
                    response.Success = response.Errors.Count == 0;
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Errors.Add("Could not process your request");
                _logger.Info("Could not map internal user to tableau account. Error " + ex.Message);
            }
            return(Json(response));
        }