public IProduct GetProduct(EProducts eproduct)
        {
            switch (eproduct)
            {
            case EProducts.Product01:
                return(new Product01());

            case EProducts.Product02:
                return(new Product02());

            case EProducts.ProductNN:
                return(new ProductNN());

            default:
                throw new NotSupportedException();
            }
        }
Example #2
0
        public EProducts AddProduct(ProductsItemsAddViewModel item)
        {
            EProducts product = new EProducts
            {
                Name        = item.Name,
                Discription = item.Discription,
                Price       = item.Price
            };

            if (item.CategoryId != null)
            {
                var category = (from p in _context.eCategories where item.CategoryId.Contains(p.Id) select p).ToList();
                if (category != null)
                {
                    product.Categories = category;
                }
            }


            _context.eProducts.Add(product);
            _context.SaveChanges();
            return(product);
        }
Example #3
0
        protected override void Seed(DatabaseContext context)
        {
            EUser admin = new EUser()
            {
                Name                 = "Sinan",
                Surname              = "Tok",
                Email                = "*****@*****.**",
                ActiveGuid           = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = true,
                Gender               = "Erkek",
                Birthday             = DateTime.Now.AddYears(-22),
                Username             = "******",
                Password             = "******",
                ProfileImageFileName = "user.jpg",
                CreatedDate          = DateTime.Now,
                ModifiedDate         = DateTime.Now.AddMinutes(5),
                ModifiedUser         = "******"
            };

            EUser standartUser = new EUser()
            {
                Name                 = "Ada",
                Surname              = "Adale",
                Email                = "*****@*****.**",
                ActiveGuid           = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = false,
                Gender               = "Kadın",
                Birthday             = DateTime.Now.AddYears(-22),
                Username             = "******",
                Password             = "******",
                ProfileImageFileName = "user.jpg",
                CreatedDate          = DateTime.Now,
                ModifiedDate         = DateTime.Now.AddMinutes(5),
                ModifiedUser         = "******"
            };

            context.EUsers.Add(admin);
            context.EUsers.Add(standartUser);

            context.SaveChanges();

            ECategories eCategories1 = new ECategories()
            {
                Title        = "Cüzdan",
                Description  = "El Yapımı Cüzdan",
                CreatedDate  = DateTime.Now,
                ModifiedDate = DateTime.Now,
                ModifiedUser = "******"
            };

            ECategories eCategories2 = new ECategories()
            {
                Title        = "Kartlık",
                Description  = "El Yapımı kartlık",
                CreatedDate  = DateTime.Now,
                ModifiedDate = DateTime.Now,
                ModifiedUser = "******"
            };

            context.ECategories.Add(eCategories1); context.ECategories.Add(eCategories2);
            context.SaveChanges();

            EProducts eProducts1 = new EProducts()
            {
                Name          = "Legos Cüzdan",
                Description   = "Minimal tasarımı ile el yapımı cüzdan",
                Price         = 1200,
                Stock         = 500,
                IsApproved    = true,
                Category      = eCategories1,
                CreatedDate   = DateTime.Now,
                ModifiedDate  = DateTime.Now,
                IsFront       = true,
                ModifiedUser  = "******",
                ImageFileName = "legos.jpeg"
            };

            EProducts eProducts2 = new EProducts()
            {
                Name          = "Legos Kartlık",
                Description   = "Minimal tasarımı ile el yapımı cüzdan",
                Price         = 1200,
                Stock         = 500,
                IsApproved    = true,
                Category      = eCategories1,
                CreatedDate   = DateTime.Now,
                ModifiedDate  = DateTime.Now,
                IsFront       = true,
                ModifiedUser  = "******",
                ImageFileName = "legos.jpeg"
            };

            context.EProducts.Add(eProducts1); context.EProducts.Add(eProducts2);
            context.SaveChanges();

            EOrders eOrders = new EOrders()
            {
                Description = "First Order",
                IsApproved  = true,
                OrderDate   = DateTime.Now,
                TotalMoney  = 2400,
                UserId      = "1",
            };

            EOrdersDetail eOrdersDetail = new EOrdersDetail()
            {
                Order    = eOrders,
                Products = eProducts1
            };

            EOrdersDetail eOrdersDetail2 = new EOrdersDetail()
            {
                Order    = eOrders,
                Products = eProducts2
            };

            context.EOrders.Add(eOrders);
            context.SaveChanges();
            context.EOrdersDetail.Add(eOrdersDetail);
            context.EOrdersDetail.Add(eOrdersDetail2);
            context.SaveChanges();
        }