コード例 #1
0
        public ActionResult AddTableauView(AHP.Web.ViewModel.TableauWorkbookViewModel tableauView)
        {
            GenericAjaxResponse <bool> response = new GenericAjaxResponse <bool>();

            try
            {
                if (ModelState.IsValid)
                {
                    AHP.Core.DTO.TableauViewInfo dto = new Core.DTO.TableauViewInfo();
                    dto.Description = string.IsNullOrEmpty(tableauView.Description) ? string.Empty : tableauView.Description.Substring(0, Math.Min(400, tableauView.Description.Length));
                    dto.Disabled    = string.IsNullOrEmpty(tableauView.Disabled) ? "N" : tableauView.Disabled;
                    dto.IsDashboard = string.IsNullOrEmpty(tableauView.IsDashboard) ? "N" : tableauView.IsDashboard;
                    dto.ViewId      = tableauView.ViewId;
                    dto.ViewName    = tableauView.ViewName;
                    dto.ViewUrl     = tableauView.ViewUrl;
                    response        = _restClient.AddTableauView(dto);
                }
                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 = response.Data = false;
                response.Errors.Add("Could not process your request. Please try again.");
                _logger.Error("Add tableau view ended up with an error", ex);
            }
            return(Json(response));
        }