public static DomUser User2DomUser(User inUser) { DomUser outUser = new DomUser(inUser.Username, inUser.LocationId, inUser.Pwrd); return(outUser); }
public void AddUser(DomUser u) { _db.User.Add(DataDomainMapper.DomUser2User(u)); _db.SaveChanges(); }
static void CreateAccount() { Console.Clear(); if (currUser != null) { Console.WriteLine("You are already signed in. Please sign out if you would like to create a new account."); WaitForInput(); return; } string uname; string pass; while (true) { Console.Clear(); Console.WriteLine("Please enter a username or type \'return\' to cancel."); uname = Console.ReadLine(); if (uname == "return") { return; } if (uRepo.UserNameTaken(uname)) { Console.WriteLine("Username already taken. Please try again."); WaitForInput(); } else { Console.WriteLine("Please enter a password or type \'return\' to cancel."); pass = Console.ReadLine(); if (pass == "return") { return; } break; } } int locId; while (true) { Console.Clear(); Console.WriteLine("Please select a store location by entering the corresponding number or enter \'return\' to cancel."); List <DomLocation> locList = lRepo.GetLocationList(); foreach (var loc in locList) { Console.WriteLine($"({loc.Id}) {loc.Address}"); } string input = Console.ReadLine(); locId = Convert.ToInt32(input); if (locId >= locList.Count || locId < 0) { Console.WriteLine("Please select a valid store number."); WaitForInput(); } else { break; } } DomUser newUser = new DomUser(uname, locId, pass); uRepo.AddUser(newUser); currUser = newUser; UpdateOrderInfo(currUser.LocationId, currUser.Username); Console.WriteLine($"Welcome to Pizza Box, {currUser.Username}!"); WaitForInput(); }