public IActionResult Get(long id)
        {
            var widgetInstance = _widgetInstanceRepository.Query().FirstOrDefault(x => x.Id == id);
            var model          = new CategoryWidgetForm
            {
                Id           = widgetInstance.Id,
                Name         = widgetInstance.Name,
                WidgetZoneId = widgetInstance.WidgetZoneId,
                PublishStart = widgetInstance.PublishStart,
                PublishEnd   = widgetInstance.PublishEnd,
                Settings     = JsonConvert.DeserializeObject <CategoryWidgetSettings>(widgetInstance.Data)
            };

            return(Json(model));
        }
        public IActionResult Put(long id, [FromBody] CategoryWidgetForm model)
        {
            if (ModelState.IsValid)
            {
                var widgetInstance = _widgetInstanceRepository.Query().FirstOrDefault(x => x.Id == id);
                widgetInstance.Name         = model.Name;
                widgetInstance.WidgetZoneId = model.WidgetZoneId;
                widgetInstance.PublishStart = model.PublishStart;
                widgetInstance.PublishEnd   = model.PublishEnd;
                widgetInstance.Data         = JsonConvert.SerializeObject(model.Settings);
                _widgetInstanceRepository.SaveChanges();
                return(Ok());
            }

            return(new BadRequestObjectResult(ModelState));
        }
        public IActionResult Post([FromBody] CategoryWidgetForm model)
        {
            if (ModelState.IsValid)
            {
                var widgetInstance = new WidgetInstance
                {
                    Name         = model.Name,
                    WidgetId     = 4,
                    WidgetZoneId = model.WidgetZoneId,
                    PublishStart = model.PublishStart,
                    PublishEnd   = model.PublishEnd,
                    Data         = JsonConvert.SerializeObject(model.Settings)
                };

                _widgetInstanceRepository.Add(widgetInstance);
                _widgetInstanceRepository.SaveChanges();
                return(Ok());
            }
            return(new BadRequestObjectResult(ModelState));
        }