Esempio n. 1
0
		public IWidgetDataBuilder GetDataBuilder(WidgetConfig widget)
		{
			if (widget == null || !WidgetDataBuilderMapper.ContainsKey(widget.WidgetId))
				return new WidgetDataBuilderNull();

			return _resolutionRoot.Get(WidgetDataBuilderMapper[widget.WidgetId]) as IWidgetDataBuilder ?? new WidgetDataBuilderNull();
		}
Esempio n. 2
0
		public void MergeConfig(WidgetConfig widgetConfig)
		{
			if (widgetConfig == null) return;

			Display = widgetConfig.Display;
			Top = widgetConfig.Top;
			Left = widgetConfig.Left;
			Width = widgetConfig.Width;
			Height = widgetConfig.Height;
		}
Esempio n. 3
0
		public void GetDataBuilder_should_return_builder_within_default_behavior_for_unknown_widget_type()
		{
			//arrange
			var widgetConfig = new WidgetConfig { WidgetId = Guid.NewGuid() };
			//act
			var actual = Target.GetDataBuilder(widgetConfig).BuildData(widgetConfig);
			//assert
			Assert.IsInstanceOfType(actual.Widget, typeof(WidgetNull));
			Assert.IsInstanceOfType(actual.Data, typeof(object));
		}
Esempio n. 4
0
		public void GetDataBuilder_should_return_builder_for_known_type()
		{
			//arrange
			var expected = new GoogleMapWidgetDataBuilder();
			Module.MethodFactory = () => expected;
			var widgetConfig = new WidgetConfig { WidgetId = new GoogleMapWidget().Id };
			//act
			var actual = Target.GetDataBuilder(widgetConfig);
			//assert
			Assert.AreSame(expected, actual);
		}
Esempio n. 5
0
		public bool SaveWidget(WidgetConfig config)
		{
			var widgets =
				_widgetsCollection.GetAllWidgetsWithinDefaultConfigu(_securityContext.CurrentUser.Roles.Select(e => e.RoleType));

			if (widgets.Any(e => e.WidgetId == config.WidgetId))
			{
				return _widgetsService.SaveWidget(config);
			}

			return false;
		}
		public WidgetViewModel BuildData(WidgetConfig widget)
		{
			var appraiser = _appraiserManagement.GetByEmail(_securityContext.CurrentUser.Email);

			var licenses = appraiser.Licenses.Select(e => e.State);
			var role = appraiser.User.PrimaryRole;
			var status = appraiser.Status;

			var viewModel = new ProfileSnapshotViewModel { Licenses = licenses, Role = role.RoleType, UserStatus = status };
			var profileSnapshotWidget = new ProfileSnapshotWidget { Display = widget.Display, Left = widget.Left, Top = widget.Top };

			return new WidgetViewModel(profileSnapshotWidget, new WidgetData<ProfileSnapshotViewModel>(profileSnapshotWidget, viewModel));
		}
		public WidgetViewModel BuildData(WidgetConfig widget)
		{
			var companyDetails = _appraiserManagement.GetByEmail(_securityContext.CurrentUser.Email).Company;

			var companyStatus = companyDetails.Status;
			var numberOfBranches = companyDetails.Branches.Count;
			var totalNumberOfUsers = _appraiserManagement.GetUsersForCompany(companyDetails.Id).Count();

			var companySnapshotWidget = new CompanySnapshotWidget { Display = widget.Display, Left = widget.Left, Top = widget.Top };
			var viewModel = new CompanySnapshotViewModel { CompanyStatus = companyStatus, NumberOfBranches = numberOfBranches, TotalNumberOfUsers = totalNumberOfUsers };

			return new WidgetViewModel(companySnapshotWidget, new WidgetData<CompanySnapshotViewModel>(companySnapshotWidget, viewModel));
		}
Esempio n. 8
0
		public bool SaveWidget(WidgetConfig config)
		{
			if (config == null) return false;

			var existsConfig =
				_widgetsRepository.GetByUserId(_securityContext.CurrentUser.Id).FirstOrDefault(e => e.WidgetId == config.WidgetId);

			if (existsConfig == null)
			{
				config.User = _securityContext.CurrentUser;
				_widgetsRepository.Add(config);
			}
			else
			{
				existsConfig.MergeConfig(config);
			}

			return true;
		}
Esempio n. 9
0
			public WidgetViewModel BuildData(WidgetConfig widget)
			{
				return new WidgetViewModel(new WidgetNull(), new WidgetData<object>(new WidgetNull(), new object()));
			}
Esempio n. 10
0
		public bool SaveWidget(WidgetConfig config)
		{
			if (config == null) return false;

			if (!Configurations.ContainsKey(_securityContext.CurrentUser.Id))
				Configurations.Add(_securityContext.CurrentUser.Id, new List<WidgetConfig>());

			var configurationsForUser = Configurations[_securityContext.CurrentUser.Id];

			var existConfiguration = configurationsForUser.FirstOrDefault(e => e.Id == config.Id);
			if (existConfiguration != null)
			{
				configurationsForUser.Remove(existConfiguration);
			}

			configurationsForUser.Add(config);

			return true;
		}
Esempio n. 11
0
		public WidgetViewModel BuildData(WidgetConfig widget)
		{
			var googleWidget = new GoogleMapWidget { Display = widget.Display, Left = widget.Left, Top = widget.Top, Size = new Size(widget.Width, widget.Height) };
			return new WidgetViewModel(googleWidget, new WidgetData<object>(googleWidget, new object()));
		}