Beispiel #1
0
        public async Task <IActionResult> AddWidget([FromBody] AddWidgetParameter model)
        {
            var success = await _service.AddWidgetToTabAsync(model.TabId, model.WidgetId);

            if (!success)
            {
                return(StatusCode((int)HttpStatusCode.ExpectationFailed,
                                  $"Widget (id:{model.WidgetId}) NOT saved."));
            }

            return(Ok());
        }
        public async Task <IActionResult> AddWidget([FromBody] AddWidgetParameter model)
        {
            var success = await _service.AddWidgetToTabAsync(model.TabId, model.WidgetId);

            var result = new TuxResponse
            {
                Success = true,
                Message = new TuxViewMessage(
                    success ? "Widget added." : "Widget was NOT added.",
                    success ? TuxMessageType.Success : TuxMessageType.Danger)
            };

            return(Json(result));
        }
Beispiel #3
0
        public async Task <IActionResult> AddWidget([FromBody] AddWidgetParameter model)
        {
            var response = await _service.AddWidgetToTabAsync(model.TabId, model.WidgetId);

            if (!response.Success)
            {
                return(StatusCode((int)HttpStatusCode.ExpectationFailed,
                                  $"Widget (id:{model.WidgetId}) NOT saved."));
            }

            var widgetPlacement = await _service.GetWidgetPlacementAsync(response.PlacementId);

            var helper       = new ViewRenderHelper(_provider);
            var viewTemplate = helper.RenderToString("WidgetTemplate",
                                                     widgetPlacement, "Components/WidgetTemplate/Default");

            return(Ok(new
            {
                response.PlacementId,
                response.Success,
                Template = viewTemplate
            }));
        }