Beispiel #1
0
        static int InsertCategory()
        {
            Console.WriteLine("Inserting category...");

            var category = new Category()
            {
                Name    = "Processors",
                Created = Timestamp,
                Updated = Timestamp
            };

            using (var uow = new TpcUnitOfWork(Context))
            {
                var categoryRepository = uow.GetRepository <Category>();
                categoryRepository.Insert(category);
                return(uow.Commit());
            }
        }
Beispiel #2
0
        // Methods
        static List <Item> GetItems()
        {
            using (var uow = new TpcUnitOfWork(Context))
            {
                // Insert item...
                var itemRepository = uow.GetRepository <Item>();

                var spec = new ExpressionSpecification <Item>()
                           .Not(i => (i.Header.Title.Contains("H")))
                           .Or(i => i.Amount >= 300);

                var include = new PropertyNavigator <Item>()
                              .Include(i => i.Header)
                              .Include(i => i.Entry)
                              .Properties;

                return(itemRepository
                       .Select(spec, include)
                       .ToList());
            }
        }
Beispiel #3
0
        static int InsertItem()
        {
            Console.WriteLine("Inserting item...");

            var header = new Header()
            {
                Title   = string.Empty.PadRight(50, 'X'),
                UserId  = 1,
                Created = Timestamp,
                Updated = Timestamp
            };
            var entry = new Entry()
            {
                Message = string.Empty.PadRight(2000, 'Y'),
                Created = Timestamp,
                Updated = Timestamp
            };
            var item = new Item()
            {
                Header     = header,
                Entry      = entry,
                CategoryId = 2,
                UserId     = 1,
                Amount     = 300,
                Section    = ItemSection.ForSale,
                Condition  = ItemCondition.BrandNew,
                Warranty   = ItemWarranty.Personal,
                Created    = Timestamp,
                Updated    = Timestamp,
                Expiry     = Timestamp.AddDays(30)
            };

            using (var uow = new TpcUnitOfWork(Context))
            {
                // Insert item...
                var itemRepository = uow.GetRepository <Item>();
                itemRepository.Insert(item);
                return(uow.Commit());
            }
        }
Beispiel #4
0
        // Methods
        static List<Item> GetItems()
        {
            using (var uow = new TpcUnitOfWork(Context))
            {
                // Insert item...
                var itemRepository = uow.GetRepository<Item>();

                var spec = new ExpressionSpecification<Item>()
                    .Not(i => (i.Header.Title.Contains("H")))
                    .Or(i => i.Amount >= 300);

                var include = new PropertyNavigator<Item>()
                    .Include(i => i.Header)
                    .Include(i => i.Entry)
                    .Properties;

                return itemRepository
                    .Select(spec, include)
                    .ToList();
            }
        }
Beispiel #5
0
        static int InsertItem()
        {
            Console.WriteLine("Inserting item...");
            
            var header = new Header()
            {
                Title = string.Empty.PadRight(50, 'X'),
                UserId = 1,
                Created = Timestamp,
                Updated = Timestamp
            };
            var entry = new Entry()
            {
                Message = string.Empty.PadRight(2000, 'Y'),
                Created = Timestamp,
                Updated = Timestamp
            };
            var item = new Item()
            {
                Header = header,
                Entry = entry,
                CategoryId = 2,
                UserId = 1,
                Amount = 300,
                Section = ItemSection.ForSale,
                Condition = ItemCondition.BrandNew,
                Warranty = ItemWarranty.Personal,
                Created = Timestamp,
                Updated = Timestamp,
                Expiry = Timestamp.AddDays(30)
            };

            using (var uow = new TpcUnitOfWork(Context))
            {
                // Insert item...
                var itemRepository = uow.GetRepository<Item>();
                itemRepository.Insert(item);
                return uow.Commit();
            }
        }
Beispiel #6
0
        static int InsertCategory()
        {
            Console.WriteLine("Inserting category...");
            
            var category = new Category()
            {
                Name = "Processors",
                Created = Timestamp,
                Updated = Timestamp
            };

            using (var uow = new TpcUnitOfWork(Context))
            {
                var categoryRepository = uow.GetRepository<Category>();
                categoryRepository.Insert(category);
                return uow.Commit();
            }
        }