Пример #1
0
        public string RegisterUser(RegisterModel model)
        {
            try
            {
                using (context = new WebStoreDbContext())
                {
                    Person user = context.People.Where(x => x.Email == model.Email).FirstOrDefault();
                    if (user == null)
                    {
                        Person person = new Person()
                        {
                            Email     = model.Email,
                            Password  = model.Password, // PasswordHash
                            FirstName = model.FirstName,
                            LastName  = model.LastName,
                            CreatedAt = DateTime.Now,
                            IsDeleted = false
                        };

                        context.People.Add(person);
                        context.SaveChanges();

                        return("");
                    }
                }
                return("Not added");
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Пример #2
0
        private void InitialUserLogin(WebStoreDbContext context)
        {
            var manager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new WebStoreDbContext()));

            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(new WebStoreDbContext()));

            var user = new ApplicationUser()
            {
                UserName       = "******",
                Email          = "*****@*****.**",
                EmailConfirmed = true,
                BirthDay       = DateTime.Now,
                FullName       = "Nghi Vo"
            };

            manager.Create(user, "@123456@");

            if (!roleManager.Roles.Any())
            {
                roleManager.Create(new IdentityRole {
                    Name = "Admin"
                });
                roleManager.Create(new IdentityRole {
                    Name = "User"
                });
            }

            var adminUser = manager.FindByEmail("*****@*****.**");

            manager.AddToRoles(adminUser.Id, new string[] { "Admin", "User" });
        }
Пример #3
0
 public CatalogController(IProductBusinessLogic productBusinessLogic,
                          IProductImagesBusinessLogic productImagesBusinessLogic,
                          IMapper mapper, WebStoreDbContext context)
 {
     _mapper  = mapper;
     _context = context;
     _productBusinessLogic       = productBusinessLogic;
     _productImagesBusinessLogic = productImagesBusinessLogic;
 }
Пример #4
0
      public ActionResult GetCollection(int collectionID)
      {
          Collection collection = null;

          using (var cnx = new WebStoreDbContext())
          {
              //collection = cnx.Collections.FirstOrDefault(c => c.CollectionID == collectionID)
              ViewBag.CollectionID = collectionID;
          }

          return(View("collection"));
      }
Пример #5
0
        private void InitialSlides(WebStoreDbContext context)
        {
            if (context.Slides.Count() == 0)
            {
                List <Slide> slides = new List <Slide>()
                {
                    new Slide()
                    {
                        Name         = "<span>E</span>-SHOPPER",
                        Description  = "Free E-Commerce Template",
                        Image        = "/Assets/client/images/home/girl1.jpg",
                        Url          = "#",
                        DisplayOrder = 1,
                        Status       = true,
                        Content      = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
                    },
                    new Slide()
                    {
                        Name         = "<span>E</span>-SHOPPER",
                        Description  = "100% Responsive Design",
                        Image        = "/Assets/client/images/home/girl2.jpg",
                        Url          = "#",
                        DisplayOrder = 2,
                        Status       = true,
                        Content      = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
                    },
                    new Slide()
                    {
                        Name         = "<span>E</span>-SHOPPER",
                        Description  = "Free Ecommerce Template",
                        Image        = "/Assets/client/images/home/girl3.jpg",
                        Url          = "#",
                        DisplayOrder = 3,
                        Status       = true,
                        Content      = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
                    }
                };

                context.Slides.AddRange(slides);
                context.SaveChanges();
            }
        }
Пример #6
0
 private void InitialProductCategory(WebStoreDbContext context)
 {
     if (context.ProductCategories.Count() == 0)
     {
         List <ProductCategory> list = new List <ProductCategory>()
         {
             new ProductCategory()
             {
                 Name = "Điện lạnh", Alias = "dien-lanh", Status = true
             },
             new ProductCategory()
             {
                 Name = "Viễn thông", Alias = "vien-thong", Status = true
             },
             new ProductCategory()
             {
                 Name = "Đồ gia dụng", Alias = "do-gia-dung", Status = true
             },
         };
         context.ProductCategories.AddRange(list);
         context.SaveChanges();
     }
 }
Пример #7
0
        public static void Initialize(WebStoreDbContext context)
        {
            context.Database.EnsureCreated();
            if (!context.Product.Any())
            {
                var deps = new Product[]
                {
                    new Product()
                    {
                        Name = "Product 01"
                    },
                    new Product()
                    {
                        Name = "Product 02"
                    }
                };
                foreach (var item in deps)
                {
                    context.Product.Add(item);
                }
                context.SaveChanges();
            }

            if (!context.ProductStatus.Any())
            {
                var companies = new ProductStatus[]
                {
                    new ProductStatus()
                    {
                        Name = "New"
                    }
                };
                foreach (var item in companies)
                {
                    context.ProductStatus.Add(item);
                }
                context.SaveChanges();
            }
            if (!context.ProductAvailabilityStatus.Any())
            {
                var companies = new ProductAvailabilityStatus[]
                {
                    new ProductAvailabilityStatus()
                    {
                        Name = "Available"
                    },
                    new ProductAvailabilityStatus()
                    {
                        Name = "Not Available"
                    }
                };
                foreach (var item in companies)
                {
                    context.ProductAvailabilityStatus.Add(item);
                }
                context.SaveChanges();
            }
            if (!context.ProductColor.Any())
            {
                var companies = new ProductColor[]
                {
                    new ProductColor()
                    {
                        Name = "White"
                    },
                    new ProductColor()
                    {
                        Name = "Black"
                    }
                };
                foreach (var item in companies)
                {
                    context.ProductColor.Add(item);
                }
                context.SaveChanges();
            }
            if (!context.ProductMetal.Any())
            {
                var companies = new ProductMetal[]
                {
                    new ProductMetal()
                    {
                        Name = "Gold"
                    },
                    new ProductMetal()
                    {
                        Name = "Silver"
                    }
                };
                foreach (var item in companies)
                {
                    context.ProductMetal.Add(item);
                }
                context.SaveChanges();
            }
            if (!context.ProductType.Any())
            {
                var types = new ProductType[]
                {
                    new ProductType()
                    {
                        Name = "Ring"
                    },
                    new ProductType()
                    {
                        Name = "Earring"
                    }
                };
                foreach (var item in types)
                {
                    context.ProductType.Add(item);
                }
                context.SaveChanges();
            }
            if (!context.Gender.Any())
            {
                var items = new Gender[]
                {
                    new Gender()
                    {
                        Name = "Чоловіча"
                    },
                    new Gender()
                    {
                        Name = "Жіноча"
                    }
                };
                foreach (var item in items)
                {
                    context.Gender.Add(item);
                }
                context.SaveChanges();
            }
        }
Пример #8
0
 public ProductapiController(WebStoreDbContext context)
 {
     _context = context;
 }
Пример #9
0
 public UserManager(WebStoreDbContext data, IOptions <TokenModel> tokenManagement)
 {
     this.dbContext        = data;
     this._tokenManagement = tokenManagement.Value;
 }
Пример #10
0
 public CheckoutController(WebStoreDbContext context, IConfiguration configuration)
 {
     _context = context;
 }
Пример #11
0
 public InDbProductData(WebStoreDbContext db)
 {
     _db = db;
 }
Пример #12
0
 public CartController(WebStoreDbContext context)
 {
     _context = context;
 }
Пример #13
0
 public FilterController(WebStoreDbContext context, IProductBusinessLogic productBusinessLogic, IMapper mapper)
 {
     _context = context;
     _productBusinessLogic = productBusinessLogic;
     _mapper = mapper;
 }
Пример #14
0
 public ProductMetalRepository(WebStoreDbContext context)
 {
     _context = context;
 }
Пример #15
0
 public GenderRepository(WebStoreDbContext context)
 {
     _context = context;
 }
Пример #16
0
 public ProductRepository(WebStoreDbContext context)
 {
     this.context = context;
 }
Пример #17
0
 public CategoryRepository(WebStoreDbContext context)
 {
     this.context = context;
 }
Пример #18
0
 public LoginController(WebStoreDbContext context)
 {
     _context = context;
 }
Пример #19
0
 public EmployeeRepository(WebStoreDbContext context)
 {
     _context = context;
 }
Пример #20
0
 public BaseManager(WebStoreDbContext db)
 {
     this.context = db;
 }
Пример #21
0
 public UsersRepository(WebStoreDbContext context) : base(context)
 {
 }
Пример #22
0
 public WebStoreDbContext Init()
 {
     return(dbContext ?? (dbContext = new WebStoreDbContext()));
 }
Пример #23
0
 public static void Initialize(WebStoreDbContext context)
 {
     context.Database.EnsureCreated();
 }
Пример #24
0
 public ProductColorRepository(WebStoreDbContext context)
 {
     _context = context;
 }
Пример #25
0
 public ProductRepository(WebStoreDbContext webStoreDbContext)
 {
     _context = webStoreDbContext;
 }
Пример #26
0
        public BaseRepository(WebStoreDbContext context)
        {
            this.Context = context ?? throw new ArgumentException("An instance of context is null");

            this.DbSet = this.Context.Set <T>();
        }
 public ProductStatusRepository(WebStoreDbContext context)
 {
     _context = context;
 }
Пример #28
0
 public InDbCartData(WebStoreDbContext db)
 {
     _db = db;
 }
Пример #29
0
 public ProductImageRepository(WebStoreDbContext context)
 {
     _context = context;
 }
Пример #30
0
 public SqlProductData(WebStoreDbContext context)
 {
     _context = context;
 }