public List <DTO_User> RegisterUser(DTO_User u) { //DB Connection DB_111206_scrapEntities db = new DB_111206_scrapEntities(); List <DTO_User> tempList = new List <DTO_User>(); tempList.Add(u); var temp = new Scrap_DAL.User { //no userid because system creates it email = u.Email, fName = u.FirstName, lName = u.LastName, phone = u.Phone, pwd = u.Password, }; db.Users.Add(temp); var loginItem = new Scrap_DAL.UserLogin { userID = temp.userID, lat = Convert.ToSingle(temp.lat), lon = Convert.ToSingle(temp.lon), logInDateTime = DateTime.Now }; db.UserLogins.Add(loginItem); db.SaveChanges(); return(tempList); }
public DTO_User VerifyUserLogin(DTO_Login uL) { //DB Connection DB_111206_scrapEntities db = new DB_111206_scrapEntities(); //get table contents var listUsers = db.Users.ToList(); var tempUser = listUsers.Where(x => x.email == uL.Email && x.pwd == uL.Password).FirstOrDefault(); //create list to return with sql objects DTO_User user = new DTO_User(); if (tempUser != null) { DTO_User verifiedUser = new DTO_User { id = tempUser.userID, FirstName = tempUser.fName, LastName = tempUser.lName, Phone = tempUser.phone, Password = tempUser.pwd }; //Add user to list for returning user = verifiedUser; //create odbject for UserLogins var loginItem = new Scrap_DAL.UserLogin { userID = tempUser.userID, lat = Convert.ToDouble(tempUser.lat), lon = Convert.ToDouble(tempUser.lon), logInDateTime = DateTime.Now }; db.UserLogins.Add(loginItem); db.SaveChanges(); } return(user); }