public static user Testing() { user user = new user(); user.Email = "test"; user.Password = "******"; user.Name = "test"; user.Surname = "test"; user.watchlist = ""; using (var context = new HotSaleDBEntities()) { context.users.Add(user); context.SaveChanges(); } user User; using (var context = new HotSaleDBEntities()) { User = context.users.ToList().SingleOrDefault(x => x.Email == user.Email); } return User; }
public static User CreateUser(User User) { user user = new user(); user.Email = User.Email; user.Password = User.Password; user.Name = User.Name; user.Surname = User.Surname; user.watchlist = ""; bool check = true; using (var context = new HotSaleDBEntities()) { if (context.users.ToList().SingleOrDefault(x => x.Email == User.Email) == null) { context.users.Add(user); context.SaveChanges(); check = false; } } if(check) { return new User(); } return User; }