예제 #1
0
        public IHttpActionResult AddNewWidgetToDashboard([FromBody] AddWidgetDTO model)
        {
            UnitOfWorkManager uowManager = new UnitOfWorkManager();

            widgetManager = new WidgetManager(uowManager);
            itemManager   = new ItemManager(uowManager);

            Dashboard dash = widgetManager.GetDashboard(User.Identity.GetUserId());

            List <PropertyTag> propertyTags = new List <PropertyTag> {
                new PropertyTag()
                {
                    Name = model.PropertyTag
                }
            };

            List <Item> items = itemManager.GetAllItems().Where(i => model.ItemIds.Contains(i.ItemId)).ToList();

            if (string.IsNullOrEmpty(model.Title))
            {
                model.Title = Resources.Title;
            }

            widgetManager.AddWidget(WidgetType.GraphType, model.Title, 0,
                                    0, propertyTags, graphType: model.GraphType, dashboardId: dash.DashboardId, items: items);

            uowManager.Save();

            return(StatusCode(HttpStatusCode.NoContent));
        }