public void Create()
        {
            //Arrange
            Identity item = new Identity()
            {
                GUID    = "test",
                Picture = "test"
            };

            //Act
            repository.Create(item);
            context.SaveChanges();
            var result = repository.GetAll().ToList();

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(IEnumerable <Identity>));
            Assert.AreEqual(209, result.Count);
            Assert.AreEqual(209, result.Last().ID);
            Assert.AreEqual(item, result.Last());
        }
示例#2
0
        public List <ApplicationUser> GetUserOfRole(string role)
        {
            var userNameList = _userRoleRepository.GetAll().Where(p => p.RoleId == role).ToList();
            List <ApplicationUser> listAppUser = new List <ApplicationUser>();

            if (userNameList != null)
            {
                foreach (var user in userNameList)
                {
                    listAppUser.Add(_userRepository.SelectById(user.UserId));
                }
            }

            return(listAppUser);
        }
示例#3
0
 public int Count()
 {
     return(_roleRepository.GetAll().Count());
 }
示例#4
0
        public void InitializeDb()
        {
            InitializeObjects();

            IdentityRepository.CreateRole(new Role()
            {
                Name = Constants.UserRoleName
            });

            IdentityRepository.CreateRole(new Role()
            {
                Name = Constants.AdminRoleName
            });

            var users = Builder <User>
                        .CreateListOfSize(_dataCount)
                        .All()
                        .Build();

            foreach (var user in users)
            {
                IdentityRepository.Create(user);
            }
            Context.SaveChanges();

            users = IdentityRepository.GetAll().ToList();


            var orderCategories = Builder <OrderCategory>
                                  .CreateListOfSize(_dataCount)
                                  .Build();

            var providerCategories = Builder <ProviderCategory>
                                     .CreateListOfSize(_dataCount)
                                     .Build();

            var orders = Builder <Order>
                         .CreateListOfSize(_dataCount)
                         .All()
                         .With(o => o.Creator  = Pick <User> .RandomItemFrom(users))
                         .With(o => o.Category = Pick <OrderCategory> .RandomItemFrom(orderCategories))
                         .With(o => o.Closed   = false)
                         .With(o => o.Approved = true)
                         .Build();

            var providers = Builder <Provider>
                            .CreateListOfSize(_dataCount)
                            .All()
                            .With(p => p.Creator  = Pick <User> .RandomItemFrom(users))
                            .With(p => p.Category = Pick <ProviderCategory> .RandomItemFrom(providerCategories))
                            .With(p => p.Approved = true)
                            .Build();

            var orderResponses = Builder <OrderResponse>
                                 .CreateListOfSize(_dataCount)
                                 .All()
                                 .With(or => or.Provider  = Pick <Provider> .RandomItemFrom(providers))
                                 .With(or => or.Order     = Pick <Order> .RandomItemFrom(orders))
                                 .With(or => or.Creator   = or.Provider.Creator)
                                 .With(or => or.Completed = false)
                                 .Build();

            var providerResponses = Builder <ProviderResponse>
                                    .CreateListOfSize(_dataCount)
                                    .All()
                                    .With(pr => pr.Order    = Pick <Order> .RandomItemFrom(orders))
                                    .With(pr => pr.Provider = Pick <Provider> .RandomItemFrom(providers))
                                    .With(pr => pr.Creator  = pr.Order.Creator)
                                    .Build();

            var images = Builder <Image>
                         .CreateListOfSize(_dataCount)
                         .Build();

            Context.Photos.AddOrUpdate(x => x.Id, images.ToArray());
            Context.ProviderCategories.AddOrUpdate(x => x.Id, providerCategories.ToArray());
            Context.OrderCategories.AddOrUpdate(x => x.Id, orderCategories.ToArray());
            Context.SaveChanges();
            Context.Orders.AddOrUpdate(x => x.Id, orders.ToArray());
            Context.Providers.AddOrUpdate(x => x.Id, providers.ToArray());
            Context.SaveChanges();
            Context.OrderResponses.AddOrUpdate(x => x.Id, orderResponses.ToArray());
            Context.ProviderResponses.AddOrUpdate(x => x.Id, providerResponses.ToArray());
            Context.SaveChanges();
        }
示例#5
0
        public List <ApplicationUser> GetAll()
        {
            var querys = _userRepository.GetAll().Where(p => p.isDelete == false);

            return(querys.ToList());
        }