Пример #1
0
        public override async Task LoadRelationsAsync(ComputerDatabaseContext context,
                                                      DbEntityEntry <GraphicsCard> entry)
        {
            await entry.Reference(entity => entity.Brand).LoadAsync();

            await entry.Reference(entity => entity.ChipsetBrand).LoadAsync();
        }
Пример #2
0
        protected override async Task <List <Chipset> > GetEntitiesAsync(
            ComputerDatabaseContext context, bool paging)
        {
            var query          = context.Chipsets.AsQueryable();
            var totalItemCount = await query.CountAsync();

            if (!string.IsNullOrWhiteSpace(View.EntityName))
            {
                query = query.Where(entity => entity.Name.Contains(View.EntityName));
            }

            if (!string.IsNullOrWhiteSpace(View.ChipsetBrand))
            {
                query = query.Where(entity => entity.Brand.Name.Contains(View.ChipsetBrand));
            }

            query = View.OrderIndex switch
            {
                1 => query.OrderByDescending(entity => entity.Id),   // Yeniden eskiye
                2 => query.OrderBy(entity => entity.Name),           // İsme göre (A-Z)
                3 => query.OrderByDescending(entity => entity.Name), // İsme göre (Z-A)
                4 => query.OrderBy(entity => entity.Brand.Name),     // Marka ismine göre (A-Z)
                5 => query.OrderByDescending(entity
                                             => entity.Brand.Name),  // Marka ismine göre (Z-A)
                _ => query.OrderBy(entity => entity.Id)              // Eskiden yeniye
            };

            return(await RunQueryAsync(query, totalItemCount, paging));
        }
Пример #3
0
        public async Task SetCountToolTips()
        {
            using var context = new ComputerDatabaseContext();
            var brandsCount = await context.Brands.CountAsync();

            var buildsCount = await context.Builds.CountAsync();

            var chipsetsCount = await context.Chipsets.CountAsync();

            var graphicsCardsCount = await context.GraphicsCards.CountAsync();

            var memoriesCount = await context.Memories.CountAsync();

            var motherboardsCount = await context.Motherboards.CountAsync();

            var processorsCount = await context.Processors.CountAsync();

            var socketsCount = await context.Sockets.CountAsync();

            var productsCount = motherboardsCount + processorsCount + graphicsCardsCount +
                                memoriesCount;

            SetCountToolTip(brandsButton, "marka", brandsCount);
            SetCountToolTip(buildsButton, "bilgisayar", buildsCount);
            SetCountToolTip(chipsetsButton, "yonga seti", chipsetsCount);
            SetCountToolTip(graphicsCardsButton, "ekran kartı", graphicsCardsCount);
            SetCountToolTip(memoriesButton, "bellek", memoriesCount);
            SetCountToolTip(motherboardsButton, "anakart", motherboardsCount);
            SetCountToolTip(processorsButton, "işlemci", processorsCount);
            SetCountToolTip(socketsButton, "soket", socketsCount);
            SetCountToolTip(productsGroupBox, "ürün", productsCount);
        }
Пример #4
0
        public override async Task LoadRelationsAsync(ComputerDatabaseContext context,
                                                      DbEntityEntry <Processor> entry)
        {
            await entry.Reference(entity => entity.Brand).LoadAsync();

            await entry.Reference(entity => entity.Socket).LoadAsync();

            await context.Entry(entry.Entity.Socket).Reference(entity => entity.Brand).LoadAsync();
        }
Пример #5
0
        protected override async Task <List <Build> > GetEntitiesAsync(ComputerDatabaseContext context,
                                                                       bool paging)
        {
            var query          = context.Builds.AsQueryable();
            var totalItemCount = await query.CountAsync();

            query = query.OrderByDescending(entity => entity.Date);
            return(await RunQueryAsync(query, totalItemCount, paging));
        }
Пример #6
0
        public BuildPresenter(Build entity, bool adminMode) : base(entity, adminMode)
        {
            View.Text              = string.IsNullOrEmpty(Entity.Name) ? "Yeni Bilgisayar" : Entity.Name;
            View.BuildMotherboard  = entity.Motherboard;
            View.BuildProcessor    = entity.Processor;
            View.BuildGraphicsCard = entity.GraphicsCard;

            using var context  = new ComputerDatabaseContext();
            View.BuildMemories = entity.Id == 0
                ? null
                : context.BuildMemories.Where(p => p.BuildId == entity.Id).Select(p => p.Memory)
                                 .Include(p => p.Brand).ToList();
        }
Пример #7
0
        public static bool CheckDatabase()
        {
            try
            {
                using var context = new ComputerDatabaseContext();
                if (!context.Database.Exists())
                {
                    Utilities.RecursiveDelete("assets");
                    context.Database.Create();
                }
                else if (!context.Database.CompatibleWithModel(false))
                {
                    var result = Utilities.ShowError(
                        "Mevcut veri tabanı eski ve programda kullanılan modelle uyuşmuyor." +
                        Environment.NewLine +
                        "Yeni bir veri tabanı oluşturmak için eski veri tabanı silinsin mi?",
                        MessageBoxButtons.YesNo);

                    if (result == DialogResult.No)
                    {
                        return(false);
                    }

                    Utilities.RecursiveDelete("assets");
                    context.Database.Delete();
                    context.Database.Create();
                }

                return(true);
            }
            catch (SqlException e) when(e.Number == 3702)
            {
                Utilities.ShowError("Veri tabanı şu anda kullanıldığı için silinemiyor. " +
                                    "Diğer bağlantıları kapattıktan sonra veri tabanını silin.");
            }
            catch (SqlException e)
            {
                MessageBox.Show(e.ToString(), "SqlException: " + e.Number, MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            catch (Exception e)
            {
                Utilities.ShowError(e.ToString());
            }

            return(false);
        }
Пример #8
0
        public override async Task LoadRelationsAsync(ComputerDatabaseContext context,
                                                      DbEntityEntry <Build> entry)
        {
            if (entry.Entity.GraphicsCard != null)
            {
                await entry.Reference(entity => entity.GraphicsCard).LoadAsync();

                var graphicsCard = context.Entry(entry.Entity.GraphicsCard);
                await graphicsCard.Reference(entity => entity.Brand).LoadAsync();

                await graphicsCard.Reference(entity => entity.ChipsetBrand).LoadAsync();
            }

            if (entry.Entity.Motherboard != null)
            {
                await entry.Reference(entity => entity.Motherboard).LoadAsync();

                var motherboard = context.Entry(entry.Entity.Motherboard);
                await motherboard.Reference(entity => entity.Brand).LoadAsync();

                await motherboard.Reference(entity => entity.Chipset).LoadAsync();

                var chipset = context.Entry(entry.Entity.Motherboard.Chipset);
                await chipset.Reference(entity => entity.Brand).LoadAsync();

                await motherboard.Reference(entity => entity.Socket).LoadAsync();

                var socket = context.Entry(entry.Entity.Motherboard.Socket);
                await socket.Reference(entity => entity.Brand).LoadAsync();
            }

            if (entry.Entity.Processor != null)
            {
                await entry.Reference(entity => entity.Processor).LoadAsync();

                var processor = context.Entry(entry.Entity.Processor);
                await processor.Reference(entity => entity.Brand).LoadAsync();

                await processor.Reference(entity => entity.Socket).LoadAsync();

                await context.Entry(entry.Entity.Processor.Socket).Reference(entity => entity.Brand)
                .LoadAsync();
            }
        }
Пример #9
0
        public ProcessorPresenter(Processor entity, bool adminMode) : base(entity, adminMode)
        {
            View.Text                    = string.IsNullOrEmpty(Entity.Name) ? "Yeni İşlemci" : Entity.Name;
            View.ProcessorBrand          = entity.Brand;
            View.ProcessorSocket         = entity.Socket;
            View.ProcessorFamily         = entity.Family;
            View.ProcessorModel          = entity.Model;
            View.ProcessorPrice          = entity.Price;
            View.ProcessorCores          = entity.Cores;
            View.ProcessorThreads        = entity.Threads;
            View.ProcessorCacheSize      = entity.CacheSize;
            View.ProcessorFrequency      = entity.Frequency;
            View.ProcessorTurboFrequency = entity.TurboFrequency;
            View.ProcessorMaxMemory      = entity.MaxMemory;
            View.ProcessorMaxMemorySpeed = entity.MaxMemorySpeed;
            View.ProcessorIs64Bit        = entity.Is64Bit;
            View.ProcessorSupportsECC    = entity.SupportsECC;

            using var context      = new ComputerDatabaseContext();
            View.ProcessorChipsets = entity.Id == 0
                ? null
                : context.ProcessorChipsets.Where(p => p.ProcessorId == entity.Id)
                                     .Select(p => p.Chipset).Include(p => p.Brand).ToList();
        }
Пример #10
0
        protected override async Task <List <Processor> > GetEntitiesAsync(
            ComputerDatabaseContext context, bool paging)
        {
            var query          = context.Processors.AsQueryable();
            var totalItemCount = await query.CountAsync();

            //if (BuildPresenter != null && View.OnlyCompatibles)
            //    query = query.Where(entity => BuildPresenter.IsCompatibleWith(entity));

            if (!string.IsNullOrWhiteSpace(View.EntityName))
            {
                query = query.Where(entity => entity.Name.Contains(View.EntityName));
            }

            if (!string.IsNullOrWhiteSpace(View.ProcessorBrand))
            {
                query = query.Where(entity => entity.Brand.Name.Contains(View.ProcessorBrand));
            }

            if (!string.IsNullOrWhiteSpace(View.ProcessorFamily))
            {
                query = query.Where(entity => entity.Family.Contains(View.ProcessorFamily));
            }

            if (!string.IsNullOrWhiteSpace(View.ProcessorSocket))
            {
                query = query.Where(entity => entity.Socket.Name.Contains(View.ProcessorSocket));
            }

            if (View.ProcessorMinPrice.HasValue)
            {
                query = query.Where(entity => entity.Price >= View.ProcessorMinPrice.Value);
            }

            if (View.ProcessorMaxPrice.HasValue)
            {
                query = query.Where(entity => entity.Price <= View.ProcessorMaxPrice.Value);
            }

            if (View.ProcessorMinCores.HasValue)
            {
                query = query.Where(entity => entity.Cores >= View.ProcessorMinCores.Value);
            }

            if (View.ProcessorMaxCores.HasValue)
            {
                query = query.Where(entity => entity.Cores <= View.ProcessorMaxCores.Value);
            }

            if (View.ProcessorMinThreads.HasValue)
            {
                query = query.Where(entity => entity.Threads >= View.ProcessorMinThreads.Value);
            }

            if (View.ProcessorMaxThreads.HasValue)
            {
                query = query.Where(entity => entity.Threads <= View.ProcessorMaxThreads.Value);
            }

            if (View.ProcessorMinCacheSize.HasValue)
            {
                query = query.Where(entity => entity.CacheSize >= View.ProcessorMinCacheSize.Value);
            }

            if (View.ProcessorMaxCacheSize.HasValue)
            {
                query = query.Where(entity => entity.CacheSize <= View.ProcessorMaxCacheSize.Value);
            }

            if (View.ProcessorMinFrequency.HasValue)
            {
                query = query.Where(entity => entity.Frequency >= View.ProcessorMinFrequency.Value);
            }

            if (View.ProcessorMaxFrequency.HasValue)
            {
                query = query.Where(entity => entity.Frequency <= View.ProcessorMaxFrequency.Value);
            }

            if (View.ProcessorMinTurboFrequency.HasValue)
            {
                query = query.Where(entity
                                    => entity.TurboFrequency >= View.ProcessorMinTurboFrequency.Value);
            }

            if (View.ProcessorMaxTurboFrequency.HasValue)
            {
                query = query.Where(entity
                                    => entity.TurboFrequency <= View.ProcessorMaxTurboFrequency.Value);
            }

            if (View.ProcessorMinMaxMemory.HasValue)
            {
                query = query.Where(entity => entity.MaxMemory >= View.ProcessorMinMaxMemory.Value);
            }

            if (View.ProcessorMaxMaxMemory.HasValue)
            {
                query = query.Where(entity => entity.MaxMemory <= View.ProcessorMaxMaxMemory.Value);
            }

            if (View.ProcessorMinMaxMemorySpeed.HasValue)
            {
                query = query.Where(entity
                                    => entity.MaxMemorySpeed >= View.ProcessorMinMaxMemorySpeed.Value);
            }

            if (View.ProcessorMaxMaxMemorySpeed.HasValue)
            {
                query = query.Where(entity
                                    => entity.MaxMemorySpeed <= View.ProcessorMaxMaxMemorySpeed.Value);
            }

            if (View.ProcessorSupportsECC != CheckState.Indeterminate)
            {
                query = query.Where(entity
                                    => entity.SupportsECC == (View.ProcessorSupportsECC == CheckState.Checked));
            }

            if (View.ProcessorIs64Bit != CheckState.Indeterminate)
            {
                query = query.Where(entity
                                    => entity.Is64Bit == (View.ProcessorIs64Bit == CheckState.Checked));
            }

            query = View.OrderIndex switch
            {
                1 => query.OrderByDescending(entity => entity.Id),         // Yeniden eskiye
                2 => query.OrderBy(entity => entity.Name),                 // İsme göre (A-Z)
                3 => query.OrderByDescending(entity => entity.Name),       // İsme göre (Z-A)
                4 => query.OrderBy(entity => entity.Brand.Name),           // Marka ismine göre (A-Z)
                5 => query.OrderByDescending(entity
                                             => entity.Brand.Name),        // Marka ismine göre (Z-A)
                6 => query.OrderBy(entity => entity.Price),                // Fiyata göre (En ucuz)
                7 => query.OrderByDescending(entity => entity.Price),      // Fiyata göre (En pahalı)
                8 => query.OrderBy(entity => entity.Family),               // Serisine göre (A-Z)
                9 => query.OrderByDescending(entity => entity.Family),     // Serisine göre (Z-A)
                10 => query.OrderBy(entity => entity.Cores),               // Çekirdek sayısına göre (En az)
                11 => query.OrderByDescending(entity
                                              => entity.Cores),            // Çekirdek sayısına göre (En çok)
                12 => query.OrderBy(entity => entity.Threads),             // İş parçacığı sayısına göre (En az)
                13 => query.OrderByDescending(entity
                                              => entity.Threads),          // İş parçacığı sayısına göre (En çok)
                14 => query.OrderBy(entity => entity.CacheSize),           // Önbellek boyutuna göre (En az)
                15 => query.OrderByDescending(entity
                                              => entity.CacheSize),        // Önbellek boyutuna göre (En çok)
                16 => query.OrderBy(entity => entity.Frequency),           // Hızına göre (En yavaş)
                17 => query.OrderByDescending(entity => entity.Frequency), // Hızına göre (En hızlı)
                18 => query.OrderBy(entity
                                    => entity.TurboFrequency),             // Maks. hızına göre (En yavaş)
                19 => query.OrderByDescending(entity
                                              => entity.TurboFrequency),   // Maks. hızına göre (En hızlı)
                20 => query.OrderBy(entity
                                    => entity.MaxMemory),                  // Maks. bellek boyutuna göre (En az)
                21 => query.OrderByDescending(entity
                                              => entity.MaxMemory),        // Maks. bellek boyutuna göre (En çok)
                22 => query.OrderBy(entity
                                    => entity.MaxMemorySpeed),             // Maks. bellek hızına göre (En yavaş)
                23 => query.OrderByDescending(entity
                                              => entity.MaxMemorySpeed),   // Maks. bellek hızına göre (En hızlı)
                _ => query.OrderBy(entity => entity.Id)                    // Eskiden yeniye
            };

            return(await RunQueryAsync(query, totalItemCount, paging));
        }
Пример #11
0
 public override async Task LoadRelationsAsync(ComputerDatabaseContext context,
                                               DbEntityEntry <Chipset> entry)
 => await entry.Reference(entity => entity.Brand).LoadAsync();
Пример #12
0
 public override async Task LoadRelationsAsync(ComputerDatabaseContext context,
                                               DbEntityEntry <Brand> entry)
 => await Task.Delay(1);
Пример #13
0
        protected override async Task <List <Memory> > GetEntitiesAsync(
            ComputerDatabaseContext context, bool paging)
        {
            var query          = context.Memories.AsQueryable();
            var totalItemCount = await query.CountAsync();

            //if (BuildPresenter != null && View.OnlyCompatibles)
            //    query = query.Where(entity => BuildPresenter.IsCompatibleWith(entity, true));

            if (!string.IsNullOrWhiteSpace(View.EntityName))
            {
                query = query.Where(entity => entity.Name.Contains(View.EntityName));
            }

            if (!string.IsNullOrWhiteSpace(View.MemoryBrand))
            {
                query = query.Where(entity => entity.Brand.Name.Contains(View.MemoryBrand));
            }

            if (!string.IsNullOrWhiteSpace(View.MemoryType))
            {
                query = query.Where(entity => entity.Type.Contains(View.MemoryType));
            }

            if (View.MemoryCount.HasValue)
            {
                query = query.Where(entity => entity.Count == View.MemoryCount.Value);
            }

            if (View.MemoryMinCapacity.HasValue)
            {
                query = query.Where(entity
                                    => entity.Capacity * entity.Count >= View.MemoryMinCapacity.Value);
            }

            if (View.MemoryMaxCapacity.HasValue)
            {
                query = query.Where(entity
                                    => entity.Capacity * entity.Count <= View.MemoryMaxCapacity.Value);
            }

            if (View.MemoryMinFrequency.HasValue)
            {
                query = query.Where(entity => entity.Frequency >= View.MemoryMinFrequency.Value);
            }

            if (View.MemoryMaxFrequency.HasValue)
            {
                query = query.Where(entity => entity.Frequency <= View.MemoryMaxFrequency.Value);
            }

            if (View.MemoryMinPrice.HasValue)
            {
                query = query.Where(entity => entity.Price >= View.MemoryMinPrice.Value);
            }

            if (View.MemoryMaxPrice.HasValue)
            {
                query = query.Where(entity => entity.Price <= View.MemoryMaxPrice.Value);
            }

            if (View.MemoryHasECC != CheckState.Indeterminate)
            {
                query = query.Where(entity
                                    => entity.HasECC == (View.MemoryHasECC == CheckState.Checked));
            }

            if (View.MemoryIsBuffered != CheckState.Indeterminate)
            {
                query = query.Where(entity
                                    => entity.IsBuffered == (View.MemoryIsBuffered == CheckState.Checked));
            }

            query = View.OrderIndex switch
            {
                1 => query.OrderByDescending(entity => entity.Id),                // Yeniden eskiye
                2 => query.OrderBy(entity => entity.Name),                        // İsme göre (A-Z)
                3 => query.OrderByDescending(entity => entity.Name),              // İsme göre (Z-A)
                4 => query.OrderBy(entity => entity.Brand.Name),                  // Marka ismine göre (A-Z)
                5 => query.OrderByDescending(entity
                                             => entity.Brand.Name),               // Marka ismine göre (Z-A)
                6 => query.OrderBy(entity => entity.Price),                       // Fiyata göre (En ucuz)
                7 => query.OrderByDescending(entity => entity.Price),             // Fiyata göre (En pahalı)
                8 => query.OrderBy(entity => entity.Type),                        // Tipe göre (A-Z)
                9 => query.OrderByDescending(entity => entity.Type),              // Tipe göre (Z-A)
                10 => query.OrderBy(entity
                                    => entity.Frequency),                         // Hıza/Bant Genişliğine göre (En yavaş)
                11 => query.OrderByDescending(entity
                                              => entity.Frequency),               // Hıza/Bant Genişliğine göre (En hızlı)
                12 => query.OrderBy(entity
                                    => entity.Capacity * entity.Count),           // Kapasiteye göre (En az)
                13 => query.OrderByDescending(entity
                                              => entity.Capacity * entity.Count), // Kapasiteye göre (En çok)
                14 => query.OrderBy(entity => entity.Count),                      // Modül sayısına göre (En az)
                15 => query.OrderByDescending(entity
                                              => entity.Count),                   // Modül sayısına göre (En çok)
                _ => query.OrderBy(entity => entity.Id)                           // Eskiden yeniye
            };

            return(await RunQueryAsync(query, totalItemCount, paging));
        }
Пример #14
0
        protected override async Task <List <Motherboard> > GetEntitiesAsync(
            ComputerDatabaseContext context, bool paging)
        {
            var query          = context.Motherboards.AsQueryable();
            var totalItemCount = await query.CountAsync();

            //if (BuildPresenter != null && View.OnlyCompatibles)
            //    query = query.Where(entity => BuildPresenter.IsCompatibleWith(entity));

            if (!string.IsNullOrWhiteSpace(View.EntityName))
            {
                query = query.Where(entity => entity.Name.Contains(View.EntityName));
            }

            if (!string.IsNullOrWhiteSpace(View.MotherboardBrand))
            {
                query = query.Where(entity => entity.Brand.Name.Contains(View.MotherboardBrand));
            }

            if (!string.IsNullOrWhiteSpace(View.MotherboardChipset))
            {
                query = query.Where(entity
                                    => entity.Chipset.Name.Contains(View.MotherboardChipset));
            }

            if (!string.IsNullOrWhiteSpace(View.MotherboardSocket))
            {
                query = query.Where(entity => entity.Socket.Name.Contains(View.MotherboardSocket));
            }

            if (!string.IsNullOrWhiteSpace(View.MotherboardMemoryType))
            {
                query = query.Where(
                    entity => entity.MemoryType.Contains(View.MotherboardMemoryType));
            }

            if (!string.IsNullOrWhiteSpace(View.MotherboardFormFactor))
            {
                query = query.Where(
                    entity => entity.FormFactor.Contains(View.MotherboardFormFactor));
            }

            if (View.MotherboardMinMemorySlots.HasValue)
            {
                query = query.Where(entity
                                    => entity.MemorySlots >= View.MotherboardMinMemorySlots.Value);
            }

            if (View.MotherboardMaxMemorySlots.HasValue)
            {
                query = query.Where(entity
                                    => entity.MemorySlots <= View.MotherboardMaxMemorySlots.Value);
            }

            if (View.MotherboardMinMaxMemory.HasValue)
            {
                query = query.Where(
                    entity => entity.MaxMemory >= View.MotherboardMinMaxMemory.Value);
            }

            if (View.MotherboardMaxMaxMemory.HasValue)
            {
                query = query.Where(
                    entity => entity.MaxMemory <= View.MotherboardMaxMaxMemory.Value);
            }

            if (View.MotherboardMinMaxMemoryFrequency.HasValue)
            {
                query = query.Where(entity
                                    => entity.MaxMemoryFrequency >= View.MotherboardMinMaxMemoryFrequency.Value);
            }

            if (View.MotherboardMaxMaxMemoryFrequency.HasValue)
            {
                query = query.Where(entity
                                    => entity.MaxMemoryFrequency <= View.MotherboardMaxMaxMemoryFrequency.Value);
            }

            if (View.MotherboardMinPrice.HasValue)
            {
                query = query.Where(entity => entity.Price >= View.MotherboardMinPrice.Value);
            }

            if (View.MotherboardMaxPrice.HasValue)
            {
                query = query.Where(entity => entity.Price <= View.MotherboardMaxPrice.Value);
            }

            if (View.MotherboardSupportsECC != CheckState.Indeterminate)
            {
                query = query.Where(entity
                                    => entity.SupportsECC == (View.MotherboardSupportsECC == CheckState.Checked));
            }

            query = View.OrderIndex switch
            {
                1 => query.OrderByDescending(entity => entity.Id),           // Yeniden eskiye
                2 => query.OrderBy(entity => entity.Name),                   // İsme göre (A-Z)
                3 => query.OrderByDescending(entity => entity.Name),         // İsme göre (Z-A)
                4 => query.OrderBy(entity => entity.Brand.Name),             // Marka ismine göre (A-Z)
                5 => query.OrderByDescending(entity
                                             => entity.Brand.Name),          // Marka ismine göre (Z-A)
                6 => query.OrderBy(entity => entity.Price),                  // Fiyata göre (En ucuz)
                7 => query.OrderByDescending(entity => entity.Price),        // Fiyata göre (En pahalı)
                8 => query.OrderBy(entity => entity.MemoryType),             // Bellek tipine göre (A-Z)
                9 => query.OrderByDescending(entity
                                             => entity.MemoryType),          // Bellek tipine göre (Z-A)
                10 => query.OrderBy(entity
                                    => entity.MemorySlots),                  // Bellek slot sayısına göre (En az)
                11 => query.OrderByDescending(entity
                                              => entity.MemorySlots),        // Bellek slot sayısına göre (En çok)
                12 => query.OrderBy(entity
                                    => entity.MaxMemory),                    // Maks. bellek kapasitesine göre (En az)
                13 => query.OrderByDescending(entity
                                              => entity.MaxMemory),          //  Maks. bellek kapasitesine göre (En çok)
                14 => query.OrderBy(entity
                                    => entity.MaxMemoryFrequency),           // Maks. bellek hızına göre (En az)
                15 => query.OrderByDescending(entity
                                              => entity.MaxMemoryFrequency), // Maks. bellek hızına göre (En çok)
                16 => query.OrderBy(entity => entity.FormFactor),            // Form faktörüne göre (A-Z)
                17 => query.OrderByDescending(entity
                                              => entity.FormFactor),         // Form faktörüne göre (Z-A)
                _ => query.OrderBy(entity => entity.Id)                      // Eskiden yeniye
            };

            return(await RunQueryAsync(query, totalItemCount, paging));
        }
Пример #15
0
        protected override async Task <List <GraphicsCard> > GetEntitiesAsync(
            ComputerDatabaseContext context, bool paging)
        {
            var query          = context.GraphicsCards.AsQueryable();
            var totalItemCount = await query.CountAsync();

            //if (BuildPresenter != null && View.OnlyCompatibles)
            //    query = query.Where(entity => BuildPresenter.IsCompatibleWith(entity));

            if (!string.IsNullOrWhiteSpace(View.EntityName))
            {
                query = query.Where(entity => entity.Name.Contains(View.EntityName));
            }

            if (!string.IsNullOrWhiteSpace(View.GraphicsCardChipsetModel))
            {
                query = query.Where(entity
                                    => entity.ChipsetModel.Contains(View.GraphicsCardChipsetModel));
            }

            if (!string.IsNullOrWhiteSpace(View.GraphicsCardBrand))
            {
                query = query.Where(entity => entity.Brand.Name.Contains(View.GraphicsCardBrand));
            }

            if (!string.IsNullOrWhiteSpace(View.GraphicsCardChipsetBrand))
            {
                query = query.Where(entity
                                    => entity.ChipsetBrand.Name.Contains(View.GraphicsCardChipsetBrand));
            }

            if (!string.IsNullOrWhiteSpace(View.GraphicsCardMemoryType))
            {
                query = query.Where(entity
                                    => entity.MemoryType.Contains(View.GraphicsCardMemoryType));
            }

            if (View.GraphicsCardMinPrice.HasValue)
            {
                query = query.Where(entity => entity.Price >= View.GraphicsCardMinPrice.Value);
            }

            if (View.GraphicsCardMaxPrice.HasValue)
            {
                query = query.Where(entity => entity.Price <= View.GraphicsCardMaxPrice.Value);
            }

            if (View.GraphicsCardMinFrequency.HasValue)
            {
                query = query.Where(entity
                                    => entity.Frequency >= View.GraphicsCardMinFrequency.Value);
            }

            if (View.GraphicsCardMaxFrequency.HasValue)
            {
                query = query.Where(entity
                                    => entity.Frequency <= View.GraphicsCardMaxFrequency.Value);
            }

            if (View.GraphicsCardMinTurboFrequency.HasValue)
            {
                query = query.Where(entity
                                    => entity.TurboFrequency >= View.GraphicsCardMinTurboFrequency.Value);
            }

            if (View.GraphicsCardMaxTurboFrequency.HasValue)
            {
                query = query.Where(entity
                                    => entity.TurboFrequency <= View.GraphicsCardMaxTurboFrequency.Value);
            }

            if (View.GraphicsCardMinMemoryFrequency.HasValue)
            {
                query = query.Where(entity
                                    => entity.MemoryFrequency >= View.GraphicsCardMinMemoryFrequency.Value);
            }

            if (View.GraphicsCardMaxMemoryFrequency.HasValue)
            {
                query = query.Where(entity
                                    => entity.MemoryFrequency <= View.GraphicsCardMaxMemoryFrequency.Value);
            }

            if (View.GraphicsCardMinBusWidth.HasValue)
            {
                query = query.Where(entity
                                    => entity.BusWidth >= View.GraphicsCardMinBusWidth.Value);
            }

            if (View.GraphicsCardMaxBusWidth.HasValue)
            {
                query = query.Where(entity
                                    => entity.BusWidth <= View.GraphicsCardMaxBusWidth.Value);
            }

            if (View.GraphicsCardMinMemory.HasValue)
            {
                query = query.Where(entity => entity.Memory >= View.GraphicsCardMinMemory.Value);
            }

            if (View.GraphicsCardMaxMemory.HasValue)
            {
                query = query.Where(entity => entity.Memory <= View.GraphicsCardMaxMemory.Value);
            }

            query = View.OrderIndex switch
            {
                1 => query.OrderByDescending(entity => entity.Id),          // Yeniden eskiye
                2 => query.OrderBy(entity => entity.Name),                  // İsme göre (A-Z)
                3 => query.OrderByDescending(entity => entity.Name),        // İsme göre (Z-A)
                4 => query.OrderBy(entity => entity.Brand.Name),            // Marka ismine göre (A-Z)
                5 => query.OrderByDescending(entity
                                             => entity.Brand.Name),         // Marka ismine göre (Z-A)
                6 => query.OrderBy(entity => entity.Price),                 // Fiyata göre (En ucuz)
                7 => query.OrderByDescending(entity => entity.Price),       // Fiyata göre (En pahalı)
                8 => query.OrderBy(entity => entity.ChipsetModel),          // Yonga setine göre (A-Z)
                9 => query.OrderByDescending(entity
                                             => entity.ChipsetModel),       // Yonga setine göre (Z-A)
                10 => query.OrderBy(entity
                                    => entity.ChipsetBrand.Name),           // Yonga seti markasına göre (A-Z)
                11 => query.OrderByDescending(entity
                                              => entity.ChipsetBrand.Name), // Yonga seti markasına göre (Z-A)
                12 => query.OrderBy(entity => entity.MemoryType),           // Bellek tipine göre (A-Z)
                13 => query.OrderByDescending(entity
                                              => entity.MemoryType),        // Bellek tipine göre (Z-A)
                14 => query.OrderBy(entity => entity.Memory),               // Bellek kapasitesine göre (En az)
                15 => query.OrderByDescending(entity
                                              => entity.Memory),            // Bellek kapasitesine göre (En çok)
                16 => query.OrderBy(entity
                                    => entity.MemoryFrequency),             // Bellek hızına göre (En yavaş)
                17 => query.OrderByDescending(entity
                                              => entity.MemoryFrequency),   // Bellek hızına göre (En hızlı)
                18 => query.OrderBy(entity => entity.Frequency),            // Çekirdek hızına göre (En yavaş)
                19 => query.OrderByDescending(entity
                                              => entity.Frequency),         // Çekirdek hızına göre (En hızlı)
                20 => query.OrderBy(entity
                                    => entity.TurboFrequency),              // Maks. çekirdek hızına göre (En yavaş)
                21 => query.OrderByDescending(entity
                                              => entity.TurboFrequency),    // Maks. çekirdek hızına göre (En hızlı)
                22 => query.OrderBy(entity
                                    => entity.BusWidth),                    // Veri yolu genişliğine göre (En az)
                23 => query.OrderByDescending(entity
                                              => entity.BusWidth),          // Veri yolu genişliğine göre (En çok)
                _ => query.OrderBy(entity => entity.Id)                     // Eskiden yeniye
            };

            return(await RunQueryAsync(query, totalItemCount, paging));
        }
Пример #16
0
        internal static async Task <bool> EnsureRelationshipsAsync
        <TEntity>(this ComputerDatabaseContext context, DbEntityEntry <TEntity> entityEntry)
            where TEntity : Entity
        {
            string modelName;
            var    relatedModels = new List <(string relatedModel, int count)>();

            switch (entityEntry)
            {
            case DbEntityEntry <Brand> brand:
                modelName = "marka";
                relatedModels.Add(("yonga seti", await brand.GetCountAsync(t => t.Chipsets)));
                relatedModels.Add(("ekran kartı",
                                   await brand.GetCountAsync(t => t.GraphicsCards)));

                relatedModels.Add(("ekran kartı yonga seti",
                                   await context.GraphicsCards.CountAsync(t
                                                                          => t.ChipsetBrandId == brand.Entity.Id)));

                relatedModels.Add(("bellek", await brand.GetCountAsync(t => t.Memories)));
                relatedModels.Add(("anakart", await brand.GetCountAsync(t => t.Motherboards)));
                relatedModels.Add(("işlemci", await brand.GetCountAsync(t => t.Processors)));
                relatedModels.Add(("soket", await brand.GetCountAsync(t => t.Sockets)));
                break;

            case DbEntityEntry <Chipset> chipset:
                modelName = "yonga seti";
                relatedModels.Add(("anakart",
                                   await chipset.GetCountAsync(t => t.Motherboards)));

                break;

            case DbEntityEntry <GraphicsCard> graphicsCard:
                modelName = "ekran kartı";
                relatedModels.Add(("bilgisayar",
                                   await graphicsCard.GetCountAsync(t => t.Builds)));

                break;

            case DbEntityEntry <Motherboard> motherboard:
                modelName = "anakart";
                relatedModels.Add(
                    ("bilgisayar", await motherboard.GetCountAsync(t => t.Builds)));

                break;

            case DbEntityEntry <Processor> processor:
                modelName = "işlemci";
                relatedModels.Add(("bilgisayar", await processor.GetCountAsync(t => t.Builds)));
                break;

            case DbEntityEntry <Socket> socket:
                modelName = "soket";
                relatedModels.Add(("anakart", await socket.GetCountAsync(t => t.Motherboards)));
                relatedModels.Add(("işlemci", await socket.GetCountAsync(t => t.Processors)));
                break;

            default:
                return(true);
            }

            var relationList = new List <string>();

            foreach (var(relatedModel, count) in relatedModels)
            {
                if (count > 0)
                {
                    relationList.Add($"{count} {relatedModel}");
                }
            }

            if (relationList.Count == 0)
            {
                return(true);
            }

            string relations;

            if (relationList.Count == 1)
            {
                relations = relationList.Single();
            }
            else
            {
                relations = string.Join(", ", relationList.ToArray(), 0, relationList.Count - 1) +
                            " ve " + relationList.Last();
            }

            Utilities.ShowError($"Silmek istediğiniz '{entityEntry.Entity.Name}' adına sahip " +
                                $"{modelName} kaydına bağlı {relations} var.\r\n" +
                                $"Lütfen '{entityEntry.Entity.Name}' kaydını silmek için önce " +
                                "bu kayıtları silin.");

            return(false);
        }