예제 #1
0
        public static async Task SetPost(SubEntitiesViewModel model, IEntityService service, string function)
        {
            var date    = DateTimeExtensions.FromWebFormat(model.Date);
            var headers = await service.All(function, model.Id, date).FirstOrDefaultAsync();

            model.Headers          = headers.ToList();
            model.HeadersSelection = headers.ToList();

            bool isInSelectionMode = model.SelectedColumns != null ? true : false;

            if (isInSelectionMode)
            {
                var dto = AutoMapperConfig.MapperInstance.Map <AllSelectedDto>(model);

                model.Values = await service.AllSelected(function, dto, 1).ToListAsync();

                headers = await service.AllSelected(function, dto).FirstOrDefaultAsync();

                model.Headers = headers.ToList();
            }
            else if (!isInSelectionMode)
            {
                model.Values = await service.All(function, model.Id, date).ToListAsync();
            }
        }
예제 #2
0
        public static async Task <T> SetGet <T>(IEntityService service, IEntityException exceptionService,
                                                SubEntitiesGetDto dto, string function)
        {
            exceptionService.DoesExist(dto.Id);
            var date   = DateTimeExtensions.FromWebFormat(dto.Date);
            var values = await service.All(function, dto.Id, date, 1).ToListAsync();

            var headers = await service.All(function, dto.Id, date).FirstOrDefaultAsync();

            dto.Values           = values;
            dto.Headers          = headers;
            dto.HeadersSelection = headers;

            return(AutoMapperConfig.MapperInstance.Map <T>(dto));
        }
예제 #3
0
        public static async Task SetPost(EntitiesViewModel model, IEntityService service, string functionAll, string functionActive)
        {
            var date = DateTimeExtensions.FromWebFormat(model.Date);

            var headers = await service.All(functionActive, null, date).FirstOrDefaultAsync();

            model.Headers          = headers.ToList();
            model.HeadersSelection = headers.ToList();

            bool isInSelectionMode = model.SelectedColumns != null ? true : false;

            // ---------------------------------------------------------
            //
            // Algorithm for getting values and headers based on:
            // 1. Date update of table
            // 2. Selected Layout Mode
            // 3. Active entities
            if (isInSelectionMode)
            {
                var dtoSelected = AutoMapperConfig.MapperInstance.Map <AllSelectedDto>(model);

                if (model.IsActive)
                {
                    headers = await service.AllSelected(functionActive, dtoSelected).FirstOrDefaultAsync();

                    model.Headers = headers.ToList();
                    model.Values  = await service.AllSelected(functionActive, dtoSelected, 1).ToListAsync();
                }
                else if (!model.IsActive)
                {
                    headers = await service.AllSelected(functionAll, dtoSelected).FirstOrDefaultAsync();

                    model.Headers = headers.ToList();
                    model.Values  = await service.AllSelected(functionAll, dtoSelected, 1).ToListAsync();
                }
            }
            else if (!isInSelectionMode)
            {
                if (model.IsActive)
                {
                    model.Values = await service.All(functionActive, null, date, 1).ToListAsync();
                }
                else if (!model.IsActive)
                {
                    model.Values = await service.All(functionAll, null, date, 1).ToListAsync();
                }
            }
        }
예제 #4
0
        public async Task <string> Run()
        {
            var owners = await _ownerService.All();

            var ownersLookup = _catsReportingService.GroupCatNamesByOwnerGender(owners);

            var result = _lookupPrintingService.PrintItemsWithHyphens(ownersLookup);

            return(result);
        }
예제 #5
0
        public static async Task <T> SetLoadedGet <T>(IEntityService service,
                                                      IEntityException exceptionService,
                                                      EntitySubEntitiesGetDto dto, string function)
        {
            exceptionService.DoesExist(dto.Id);
            var date     = DateTimeExtensions.FromWebFormat(dto.Date);
            var entities = await service.All(function, dto.Id, date).ToListAsync();

            dto.Entities = entities;

            return(AutoMapperConfig.MapperInstance.Map <T>(dto));
        }
예제 #6
0
        public static async Task <T> SetGet <T>(IEntityService service, string functionActive, IEnumerable <string> userColumns)
        {
            bool isInLayoutMode = userColumns.Count() > 0 ? true : false;

            var today        = DateTime.Today;
            var primeHeaders = await service.All(functionActive, null, today).FirstOrDefaultAsync();

            var headers = await service.All(functionActive, null, today).FirstOrDefaultAsync();

            var values = await service.All(functionActive, null, today, 1).ToListAsync();

            if (isInLayoutMode)
            {
                var dtoSelected = new AllSelectedDto
                {
                    Date = today,
                    PreSelectedColumns = headers.Take(GlobalConstants.PreSelectedColumnsCount).ToList(),
                    SelectedColumns    = userColumns,
                };

                headers = await service.AllSelected(functionActive, dtoSelected).FirstOrDefaultAsync();

                values = await service.AllSelected(functionActive, dtoSelected, 1).ToListAsync();
            }

            var dto = new EntitiesOverviewGetDto()
            {
                IsActive         = true,
                Date             = DateTimeExtensions.ToWebFormat(today),
                HeadersSelection = primeHeaders,
                Headers          = headers,
                Values           = values,
                SelectedColumns  = userColumns,
            };

            return(AutoMapperConfig.MapperInstance.Map <T>(dto));
        }