示例#1
0
        public async Task DeleteUserAsync(Guid userId)
        {
            var user = await _context.Users.SingleOrDefaultAsync(p => p.Id == userId);

            if (user == null)
            {
                throw new ArgumentException("Invalid User Id");
            }
            _context.Users.Remove(user);
            await _context.SaveChangesAsync();
        }
示例#2
0
        public static async Task AddTestData(MollazDbContext context)
        {
//            if (context.Users.Any())
//            {
//                //Already has Data
//                return;
//            }

            context.Users.Add(new UserEntity()
            {
                Id          = Guid.NewGuid(),
                FirstName   = "Makinde",
                LastName    = "Ola",
                Email       = "*****@*****.**",
                Phone       = "2348152425698",
                DateCreated = DateTime.Now,
                City        = "Lekki",
                Country     = "Nigeria",
                UserName    = "******",
                Password    = "******",
            });

            context.Users.Add(new UserEntity()
            {
                Id          = Guid.NewGuid(),
                FirstName   = "Stella",
                LastName    = "Damascus",
                Email       = "*****@*****.**",
                Phone       = "2348152425699",
                DateCreated = DateTime.Now,
                City        = "Chicago",
                Country     = "United States Of America",
                UserName    = "******",
                Password    = "******",
            });
            context.Users.Add(new UserEntity()
            {
                Id          = Guid.NewGuid(),
                FirstName   = "Ezekiel",
                LastName    = "Famurewa",
                Email       = "*****@*****.**",
                Phone       = "2348152425698",
                DateCreated = DateTime.Now,
                City        = "Manchester",
                Country     = "London",
                UserName    = "******",
                Password    = "******",
            });
            var result = await context.SaveChangesAsync();
        }