public IEnumerable <PresidentInfoDto> GetAllSorted(SortOrder birthDate = SortOrder.Asc, SortOrder deathDate = SortOrder.Asc) { var result = SheetRepository.GetAllData(credentialPath); IOrderedEnumerable <PresidentInfoDto> order; if (birthDate == SortOrder.Asc) { order = result.OrderBy(x => x.Birthday); } else { order = result.OrderByDescending(x => x.Birthday); } if (birthDate == SortOrder.Asc) { order = order.ThenBy(x => (x.Deathday ?? DateTime.MaxValue)); } else { order = order.ThenBy(x => (x.Deathday ?? DateTime.MinValue)); } return(result.ToList()); }
public SheetController(EntityOwnerService entityOwnerService, SheetRepository sheetRepository, SheetRetrievalService sheetRetrievalService, SheetStatisticsService sheetStatisticsService) : base(entityOwnerService) { this._sheetRepository = sheetRepository; this._sheetRetrievalService = sheetRetrievalService; this._sheetStatisticsService = sheetStatisticsService; }
/// <summary> /// Gets the summary. /// </summary> /// <param name="sheetId">The sheet identifier.</param> /// <param name="periodIds">The period ids.</param> /// <returns> /// Collection of calculated summary cells. /// </returns> public IEnumerable <TableCell> GetSummary(Guid sheetId, IEnumerable <Guid> periodIds) { var sheet = SheetRepository.GetSheet(sheetId); var cellValues = new List <TableCell>(); var columnsToCalculate = GetColumnsToCalculate(sheetId); if (columnsToCalculate.IsEmpty()) { return(cellValues); } IEnumerable <Period> periodsInfo = PeriodRepository.GetForecastPeriods(periodIds, sheet.PeriodTypeId); EntitySchemaQuery esq = GetSummaryEsq(sheet, periodsInfo, columnsToCalculate); EntityCollection collection = esq.GetEntityCollection(UserConnection); foreach (var item in collection) { var periodName = item.GetTypedColumnValue <string>("PeriodName"); var columnId = item.GetTypedColumnValue <string>("ForecastColumnId"); var summary = item.GetTypedColumnValue <double>(_aggregationColumnName); cellValues.Add(new TableCell { ColumnCode = columnId, GroupCode = periodName, Value = summary }); } return(cellValues); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public SheetRetrievalService(SheetRepository sheetRepository, AppOwnerRepository appOwnerRepository, IMapper mappingEngine, RecurringSheetEntryRepository recurringSheetEntryRepository) { this._sheetRepository = sheetRepository; this._appOwnerRepository = appOwnerRepository; this._mappingEngine = mappingEngine; this._recurringSheetEntryRepository = recurringSheetEntryRepository; }
///<inheritdoc /> public ForecastData GetData(Guid forecastId, FilterConfig filterConfig) { filterConfig.CheckArgumentNull(nameof(filterConfig)); filterConfig.RecordIds.CheckArgumentNull(nameof(filterConfig.RecordIds)); var sheet = SheetRepository.GetSheet(forecastId); var recordIds = filterConfig.RecordIds; IEnumerable <Period> periods = PeriodRepository.GetForecastPeriods(filterConfig.PeriodIds, sheet.PeriodTypeId); var periodIds = periods.Select(p => p.Id); var allCells = EntityInForecastCellRepository.GetCellsByRecords(sheet, periodIds, recordIds); var columns = GetColumnInfos(forecastId, periods); List <Row> rows = new List <Row>(); recordIds.ForEach(recordId => { IEnumerable <Cell> cells = allCells.Where(c => c.EntityId == recordId); rows.Add(new Row { Id = recordId, Hierarchy = new [] { new HierarchyItem() }, Cells = cells }); }); return(new ForecastData() { Rows = rows, Columns = columns }); }
public void DeleteSheet_ProvidingNull_ThrowException() { //Arrange var options = new DbContextOptionsBuilder <LibraryContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using var context = new LibraryContext(options); ISheetRepository sheetRepository = new SheetRepository(context); ICategoryRepository categoryRepository = new CategoryRepository(context); var category = new CategoryTO { Name = "Musique de films" }; var addedCategory = categoryRepository.Add(category); var category2 = new CategoryTO { Name = "Musique de classique" }; var addedCategory2 = categoryRepository.Add(category2); context.SaveChanges(); var sheet = new SheetTO { Name = "BestOf", Arranger = "Jean-Luc", Category = addedCategory, Composer = "Morricone", IsCurrent = false, IsGarde = false, IsIndependance = true }; var sheet2 = new SheetTO { Name = "Young Amadeus", Arranger = "Jan de Haan", Category = addedCategory2, Composer = "Mozart", IsCurrent = true, IsGarde = false, IsIndependance = true }; //Act & Assert Assert.ThrowsException <ArgumentException>(() => sheetRepository.Delete(sheet)); }
public SheetController(EntityOwnerService entityOwnerService, SheetRepository sheetRepository, SheetRetrievalService sheetRetrievalService, SheetStatisticsService sheetStatisticsService, IMapper mappingEngine, SheetLastVisitedMarkerService sheetLastVisitedMarkerService) : base(entityOwnerService) { this._sheetRepository = sheetRepository; this._sheetRetrievalService = sheetRetrievalService; this._sheetStatisticsService = sheetStatisticsService; this._mappingEngine = mappingEngine; this._sheetLastVisitedMarkerService = sheetLastVisitedMarkerService; }
public void FindSheet_FindIn4Sheets(int lat, int lon, string sheetName) { var sheetRepository = new SheetRepository(null, _configuration.Object); var sheet = sheetRepository.FindByCoordinatesAndScale(lat, lon, 50); Assert.Equal(sheetName, sheet.Name); }
public void FindSheet_100Scale(int lat, int lon, int scale, string sheetName) { var sheetRepository = new SheetRepository(new AmazonS3Client(new AmazonS3Config() { RegionEndpoint = RegionEndpoint.EUWest1 }), _configuration.Object); var sheet = sheetRepository.FindByCoordinatesAndScale(lat, lon, scale); Assert.Equal(sheetName, sheet.Name); }
public void AddSheet_AddNull_ThrowException() { //Arrange var options = new DbContextOptionsBuilder <LibraryContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using var context = new LibraryContext(options); ISheetRepository sheetRepository = new SheetRepository(context); //Act & Assert Assert.ThrowsException <ArgumentNullException>(() => sheetRepository.Add(null)); }
public void FindSheet_ByName(string sheetName, int lat, int lon) { var sheetRepository = new SheetRepository(new AmazonS3Client(new AmazonS3Config() { RegionEndpoint = RegionEndpoint.EUWest1 }), _configuration.Object); var sheet = sheetRepository.FindByNameAndScale(sheetName, 100); Assert.Equal(sheetName, sheet.Name); Assert.Equal(lat, sheet.Lat); Assert.Equal(lon, sheet.Lon); }
private void PreparedParameters(IDictionary <string, object> parameters) { Guid forecastId; if (Guid.TryParse(parameters["ForecastId"]?.ToString(), out forecastId)) { ForecastSheet = SheetRepository.GetSheet(forecastId); } else { throw new ArgumentNullException(paramName: "ForecastId"); } InitPeriods(parameters); }
public void UpdateSheet_ProvidingNonExistingSheet_ThrowException() { var options = new DbContextOptionsBuilder <LibraryContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using var context = new LibraryContext(options); ISheetRepository sheetRepository = new SheetRepository(context); var sheet = new SheetTO { Name = "BestOf", Arranger = "Jean-Luc", Composer = "Morricone", IsCurrent = false, IsGarde = false, IsIndependance = true }; //Act & Assert Assert.ThrowsException <ArgumentException>(() => sheetRepository.Update(sheet)); }
public void FindSheet_FindIn25Sheets() { var lat = 1494000000; var lon = 1062000000; var offset = 1800000; var sheetRepository = new SheetRepository(null, _configuration.Object); int index = 1; for (int row = 0; row < 5; row++) { for (int col = 0; col < 5; col++) { var sheet = sheetRepository.FindByCoordinatesAndScale(lat + (4 - row) * offset + 100, lon + col * offset + 100, 10); Assert.Equal(index++.ToString().PadLeft(2, '0'), sheet.Name); } } }
public void UpdateSheet_Successful() { //Arrange var options = new DbContextOptionsBuilder <LibraryContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using var context = new LibraryContext(options); ISheetRepository sheetRepository = new SheetRepository(context); ICategoryRepository categoryRepository = new CategoryRepository(context); //Act var category = new CategoryTO { Name = "Musique de films" }; var addedCategory = categoryRepository.Add(category); var category2 = new CategoryTO { Name = "Musique de classique" }; var addedCategory2 = categoryRepository.Add(category2); context.SaveChanges(); var sheet = new SheetTO { Name = "BestOf", Arranger = "Jean-Luc", Category = addedCategory, Composer = "Morricone", IsCurrent = false, IsGarde = false, IsIndependance = true }; var sheet2 = new SheetTO { Name = "Young Amadeus", Arranger = "Jan de Haan", Category = addedCategory2, Composer = "Mozart", IsCurrent = true, IsGarde = false, IsIndependance = true }; var addedSheet = sheetRepository.Add(sheet); var addedSheet2 = sheetRepository.Add(sheet2); context.SaveChanges(); //Act addedSheet.Category = addedCategory2; var test = sheetRepository.Update(addedSheet); context.SaveChanges(); //Assert Assert.AreEqual(2, sheetRepository.GetAll().Count()); Assert.AreEqual("Musique de classique", test.Category.Name); }
public void AddSheet_AddExistingSheet_DoNotInsertTwiceInDb() { //Arrange var options = new DbContextOptionsBuilder <LibraryContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using var context = new LibraryContext(options); ISheetRepository sheetRepository = new SheetRepository(context); ICategoryRepository categoryRepository = new CategoryRepository(context); //Act var category = new CategoryTO { Name = "Musique de films" }; var addedCategory = categoryRepository.Add(category); var category2 = new CategoryTO { Name = "Musique de classique" }; var addedCategory2 = categoryRepository.Add(category2); context.SaveChanges(); var sheet = new SheetTO { Name = "BestOf", Arranger = "Jean-Luc", Category = addedCategory, Composer = "Morricone", IsCurrent = false, IsGarde = false, IsIndependance = true }; var sheet2 = new SheetTO { Id = 1, Name = "BestOf", Arranger = "Jean-Luc", Category = addedCategory2, Composer = "Morricone", IsCurrent = false, IsGarde = false, IsIndependance = true }; var addedSheet = sheetRepository.Add(sheet); var addedSheet2 = sheetRepository.Add(sheet2); context.SaveChanges(); //Assert Assert.IsNotNull(sheet); Assert.AreEqual(1, sheetRepository.GetAll().Count()); }
private ForecastData InnerGetData(Guid forecastId, IEnumerable <Guid> periodIds, PageableConfig pageableConfig) { forecastId.CheckArgumentEmpty(nameof(forecastId)); Sheet sheet = SheetRepository.GetSheet(forecastId); IEnumerable <Period> periods = PeriodRepository.GetForecastPeriods(periodIds, sheet.PeriodTypeId); IEnumerable <ColumnInfo> columns = GetColumnInfos(forecastId, periods); IEnumerable <HierarchyRow> hierarchyRows = ForecastHierarchyRowDataRepository .GetHierarchyRows(sheet, sheet.Setting?.Hierarchy, pageableConfig); List <Row> rows = new List <Row>(); var maxLevel = sheet.Setting?.Hierarchy?.Count() ?? 0; IEnumerable <Cell> allCells = new List <Cell>(); var hierarchy = new List <HierarchyItem>(); if ((pageableConfig.HierarchyLevel == maxLevel) && (hierarchyRows.Any())) { allCells = EntityInForecastCellRepository.GetCellsByRecords(sheet, periods.Select(e => e.Id), hierarchyRows.Select(r => r.RecordId)); hierarchy.Add(new HierarchyItem { Id = Guid.NewGuid(), Level = maxLevel }); } hierarchyRows.ForEach(hr => { IEnumerable <Cell> cells = allCells.Where(c => c.EntityId == hr.RecordId); rows.Add(new Row { Id = hr.RecordId, Value = hr.Value, Hierarchy = hierarchy, Cells = cells }); }); return(new ForecastData { Columns = columns, Rows = rows }); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public SheetRetrievalService(SheetRepository sheetRepository, AppOwnerRepository appOwnerRepository) { this._sheetRepository = sheetRepository; this._appOwnerRepository = appOwnerRepository; }
public IEnumerable <PresidentInfoDto> GetByName(string name) { return(SheetRepository .GetAllData(credentialPath) .Where(x => x.President.ToLower() == name.ToLower())); }
public IEnumerable <PresidentInfoDto> Get() { return(SheetRepository.GetAllData(credentialPath)); }
public void UpdateSheetPart_Successful() { var options = new DbContextOptionsBuilder <LibraryContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using var context = new LibraryContext(options); ISheetRepository sheetRepository = new SheetRepository(context); ICategoryRepository categoryRepository = new CategoryRepository(context); ISheetPartRepository sheetPartRepository = new SheetPartRepository(context); IInstrumentRepository instrumentRepository = new InstrumentRepository(context); //Act var category = new CategoryTO { Name = "Musique de films" }; var addedCategory = categoryRepository.Add(category); var category2 = new CategoryTO { Name = "Musique de classique" }; var addedCategory2 = categoryRepository.Add(category2); context.SaveChanges(); var sheet = new SheetTO { Name = "BestOf", Arranger = "Jean-Luc", Category = addedCategory, Composer = "Morricone", IsCurrent = false, IsGarde = false, IsIndependance = true }; var sheet2 = new SheetTO { Name = "Youg Amadeus", Arranger = "Jan de Haan", Category = addedCategory2, Composer = "Mozart", IsCurrent = true, IsGarde = false, IsIndependance = true }; var addedSheet = sheetRepository.Add(sheet); var addedSheet2 = sheetRepository.Add(sheet2); context.SaveChanges(); var instru = new InstrumentTO { Name = "Saxophone" }; var instru2 = new InstrumentTO { Name = "Trumpet" }; var instru3 = new InstrumentTO { Name = "Flute" }; var addedInstru = instrumentRepository.Add(instru); var addedInstru2 = instrumentRepository.Add(instru2); var addedInstru3 = instrumentRepository.Add(instru3); context.SaveChanges(); var sheetPart = new SheetPartTO { Instrument = addedInstru, Sheet = addedSheet, Path = @"C:\sheet" }; var sheetPart2 = new SheetPartTO { Instrument = addedInstru2, Sheet = addedSheet }; var sheetPart3 = new SheetPartTO { Instrument = addedInstru, Sheet = addedSheet2 }; var addedSheetPart = sheetPartRepository.Add(sheetPart); var addedSheetPart2 = sheetPartRepository.Add(sheetPart2); var addedSheetPart3 = sheetPartRepository.Add(sheetPart3); context.SaveChanges(); //ACT addedSheetPart.Instrument = addedInstru3; var test = sheetPartRepository.Update(addedSheetPart); context.SaveChanges(); //Assert Assert.AreEqual(3, sheetPartRepository.GetAll().Count()); Assert.AreEqual("Flute", test.Instrument.Name); }
public SheetWindow(int g_id, int s_id) { InitializeComponent(); Sheets = new SheetRepository().GetSheetsByGroupAndSubject(g_id, s_id); DataContext = this; }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public SheetStatisticsService(SheetRepository sheetRepository) { this._sheetRepository = sheetRepository; }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public SheetStatisticsService(SheetRepository sheetRepository, SheetEntryRepository sheetEntryRepository) { this._sheetRepository = sheetRepository; this._sheetEntryRepository = sheetEntryRepository; }
public SheetService() { _sheetRepository = new SheetRepository(); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public SheetOffsetCalculationService(SheetRepository sheetRepository) { this._sheetRepository = sheetRepository; }
public DelayedSheetVisitUpdateMarkerJob(SheetLastVisitedMarkerService sheetLastVisitedMarkerService, SheetRepository sheetRepository) { this._sheetLastVisitedMarkerService = sheetLastVisitedMarkerService; this._sheetRepository = sheetRepository; }