public Types.User updateUser(Types.User u) { using (var ctx = new Models.Model()) { Models.User u1 = ctx.users.FirstOrDefault(x => x.userId == u.userId); u1.username = u.username; u1.firstName = u.firstName; u1.lastName = u.lastName; u1.password = u.password; ctx.SaveChanges(); return(u); } }
public int addUser(Types.User u) { using (var ctx = new Models.Model()) { Models.User u1 = new Models.User(); u1.username = u.username; u1.firstName = u.firstName; u1.lastName = u.lastName; u1.password = u.password; ctx.users.Add(u1); ctx.SaveChanges(); return(u1.userId); } }
public Types.User verify(string username, string password) { using (var ctx = new Models.Model()) { Models.User u = ctx.users.FirstOrDefault(x => x.username == username && x.password == password); Types.User u1 = new Types.User(); u1.userId = u.userId; u1.username = u.username; u1.firstName = u.firstName; u1.lastName = u.lastName; u1.password = u.password; return(u1); } }
public Types.User getUser(int userId) { using (var ctx = new Models.Model()) { Models.User u = ctx.users.FirstOrDefault(x => x.userId == userId); Types.User u1 = new Types.User(); u1.userId = u.userId; u1.username = u.username; u1.firstName = u.firstName; u1.lastName = u.lastName; u1.password = u.password; return(u1); } }