public void calculate_its_properties_from_input()
        {
            var year  = DateTime.Today.Year;
            var month = new Month(DateTime.Today.Month);
            var model = new CreateDataSourceModel(new YearAndMonth(year, month));

            using (new AssertionScope())
            {
                for (int i = 0; i < 12; i++)
                {
                    model.FromMonths[i].Should().Be(new Month(i + 1));
                    model.ToMonths[i].Should().Be(new Month(i + 1));
                }

                model.FromYears[0].Should().Be(year - 1);
                model.FromYears[1].Should().Be(year);
                model.FromYears[2].Should().Be(year + 1);
                model.ToYears[0].Should().Be(year);
                model.ToYears[1].Should().Be(year + 1);

                model.SelectedFromMonth.Should().Be(month);
                model.SelectedFromYear.Should().Be(year);

                var fromDate = new DateTime(model.SelectedFromYear, model.SelectedFromMonth.Number, 1);
                var toDate   = new DateTime(model.SelectedToYear, model.SelectedToMonth.Number, 1);
                fromDate.AddMonths(1).Should().Be(toDate);
            }
        }
예제 #2
0
 public CreateDataSourceDialog(YearAndMonth from, Func <CopyFilesParams, Exceptional <Unit> > copyFiles)
 {
     this.copyFiles = copyFiles;
     InitializeComponent();
     model       = new CreateDataSourceModel(from);
     DataContext = model;
 }
        public ResponseWrapper <CreateDataSourceModel> CreateDataSource(CreateDataSourceInputModel model)
        {
            var newEntity = new DataSource
            {
                EntityPropertyPropertyId = model.EntityPropertyPropertyId,
                DataSourceRelationId     = model.DataSourceRelationId,
            };

            context
            .DataSources
            .Add(newEntity);

            context.SaveChanges();
            var response = new CreateDataSourceModel
            {
                DataSourceId             = newEntity.DataSourceId,
                EntityPropertyPropertyId = newEntity.EntityPropertyPropertyId,
                DataSourceRelationId     = newEntity.DataSourceRelationId,
            };

            return(new ResponseWrapper <CreateDataSourceModel>(_validationDictionary, response));
        }