コード例 #1
0
        public static User Create(User user)
        {
            user.Id = FakeDataStore.Keys.OrderBy(i => i).Last() + 1;
            FakeDataStore[user.Id] = user;

            return user;
        }
コード例 #2
0
        static UserRepository()
        {
            FakeDataStore = new Dictionary<int, User>();

            FakeDataStore[1] = new User
            {
                County = CountyEnum.Monongalia,
                Id = 1,
                Name = "Abraham Lincoln",
                Email = "*****@*****.**",
                SessionGuid = Guid.NewGuid()
            };

            FakeDataStore[2] = new User
            {
                County = CountyEnum.Marion,
                Id = 2,
                Name = "George Washington",
                Email = "*****@*****.**",
                SessionGuid = Guid.NewGuid()
            };

            var ctr = 3;

            while (ctr < 1000)
            {
                FakeDataStore[ctr] = new User
                {
                    County = (CountyEnum)Faker.RandomNumber.Next(0, 3),
                    Id = ctr,
                    Name = Faker.Name.FullName(),
                    Email = Faker.Internet.Email(),
                    SessionGuid = Guid.NewGuid()
                };

                ctr++;
            }
        }
コード例 #3
0
 public static User Update(User user)
 {
     return UserRepository.Update(user);
 }
コード例 #4
0
 public static User Create(User user)
 {
     return UserRepository.Create(user);
 }
コード例 #5
0
        public static User Update(User user)
        {
            if (!FakeDataStore.ContainsKey(user.Id)) throw new InvalidDataException("Cannot updated non-existant user");

            FakeDataStore[user.Id] = user;

            return user;
        }