コード例 #1
0
ファイル: SeedTestData.cs プロジェクト: MarekHonc/Rentals
        public static async Task Create(IRepositoriesFactory context, UserManager <User> userManager)
        {
            var customer = new User()
            {
                UserName = "******",
                Name     = "Novák Josef",
                Email    = "*****@*****.**",
                Class    = "P-2015-2019(ma)",
            };

            var createPowerUser = await userManager.CreateAsync(customer);

            if (createPowerUser.Succeeded)
            {
                // Přidání Admin role
                await userManager.AddToRoleAsync(customer, RoleType.Customer.ToString());
            }

            var sony = ItemType.CreateEntity("Kamera sony",
                                             "Digitální fotoaparát - bezzrcadlovka, Full Frame, CMOS Exmor 24.3 Mpx",
                                             new List <Item>()
            {
                Item.CreateEntity("Kamera sony_1", ""), Item.CreateEntity("Kamera sony_2", "")
            }, context,
                                             context.Rentals.GetFirst());

            var objektiv = ItemType.CreateEntity("Objektiv",
                                                 "FE 50mm f/1.8",
                                                 new List <Item>()
            {
                Item.CreateEntity("Objektiv_1", ""), Item.CreateEntity("Objektiv_2", "")
            }, context,
                                                 context.Rentals.GetFirst());

            var accessory = ItemTypeToItemType.Create(sony.Id, objektiv.Id);

            context.Accessories.Add(accessory);

            context.SaveChanges();
        }
コード例 #2
0
        /// <summary>
        /// Vytvoří entitu typu, kterou je možné vložit do databáze.
        /// </summary>
        public ItemType CreateEntity(IRepositoriesFactory factory, Rental rental)
        {
            var type = ItemType.CreateEntity(this.Name, this.Description, this.CreateItems(), factory, rental, this.Accessories, this.AccessoryTo);

            return(type);
        }