public void BuyItem(int id, int buyerId) { Item item = _itemRepository.GetAll().FirstOrDefault(i => i.Id == id); item.BuyerUserId = buyerId; _secondhandContext.SaveChanges(); }
public void UpdateUser(User user) { User update = _secondhandContext.Users.FirstOrDefault(u => u.UserName == user.UserName); if (update == null) { update = new User { UserName = user.UserName }; _secondhandContext.Users.Add(update); } update.FirstName = user.FirstName; update.LastName = user.LastName; update.Street = user.Street; update.City = user.City; update.Zip = user.Zip; update.Country = user.Country; update.Password = user.Password; _secondhandContext.SaveChanges(); }