Example #1
0
 public void Update(User entity)
 {
     Name = entity.Name;
     Number = entity.Number;
     TagId = entity.TagId;
     Meta = entity.Meta;
     Email = entity.Email;
 }
 public void Delete(User entity)
 {
     var existing = _users.SingleOrDefault(t => t.Id == entity.Id);
     if (existing != null)
     {
         _users.Remove(existing);
     }
 }
 public void Delete(User entity)
 {
     using (var ctx = new SportsRfidTimerContext())
     {
         ctx.Users.Remove(entity);
         ctx.SaveChanges();
     }
 }
        public void SaveUserShouldInsertUserIntoRepository()
        {
            var container = _registrar.Build();
            var user = new User("Jöregen Lidholm", 11);

            var repo = container.Resolve<IUserRepository>();
            repo.Save(user);
            var result = repo.Get(user.Id);
            result.Id.Should().Be(user.Id);
        }
        public void CreateUserShouldThrowOnMissingParamaters()
        {
            var act = new Action(() => { var user = new User(null, 0); });
            act.ShouldThrow<ArgumentNullException>();

            act = new Action(() => { var user = new User("", 0); });
            act.ShouldThrow<ArgumentException>();

            act = new Action(() => { var user = new User("Jörgen Lidholm", -1); });
            act.ShouldThrow<ArgumentException>();
        }
        public void UpdatingUserShouldNotInsertNewUserIntoRepository()
        {
            var container = _registrar.Build();
            var user = new User("Jöregen Lidholm", 11);

            var repo = container.Resolve<IUserRepository>();
            repo.Save(user);
            var result = repo.Get(user.Id);
            result.Id.Should().Be(user.Id);

            user.Meta = "GasGas EC 300";
            repo.Save(user);
            var users = repo.FindAll().ToArray();
            users.Count().Should().Be(1);
            users.Count(t=>t.Meta == "GasGas EC 300").Should().Be(1);
        }
 public void Save(User entity)
 {
     using (var ctx = new SportsRfidTimerContext())
     {
         var user = ctx.Users.Find(entity.Id);
         if (user != null)
         {
             user.Update(entity);
             ctx.Users.Attach(user);
         }
         else
         {
             ctx.Users.Add(entity);
         }
         if (ctx.ChangeTracker.HasChanges())
             Console.WriteLine("User Changed.");
         
         ctx.SaveChanges();
     }
 }
 public UpdateUser(User.User user)
 {
     _user = user;
 }
 public UserViewModel(User user)
 {
     _user = user;
 }