public static User Create(User user) { user.Id = FakeDataStore.Keys.OrderBy(i => i).Last() + 1; FakeDataStore[user.Id] = user; return user; }
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++; } }
public static User Update(User user) { return UserRepository.Update(user); }
public static User Create(User user) { return UserRepository.Create(user); }
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; }