private void UserLogin(User userSelection) { MenuClient <string> stringClient = new MenuClient <string>(); stringClient.Prompt = "Please login with your password"; bool passwordValid = false; //Here we enter a while loop until a valid password is entered while (passwordValid == false) { //This is checking against the stringClient's method for receiving user input //If that return value is not equal to the password of the userSelection that //was passed into the method from the posterior method. if (stringClient.GetUserInput() != userSelection.Password) { //We tell you that you entered the wrong password. Console.WriteLine("Invalid password..."); } else { //Otherwise, the only alternative is that your entry is == userSelection.Password //then we assign your selection to the CurrentUser Property of the UserManager Current = userSelection; //and your password was true after all so... passwordValid = true; } } }
public async Task <GetMenuClientOutput> GetMenuClientForEditAsync(NullableIdDto input) { MenuClient menuClient = null; if (input.Id.HasValue && input.Id.Value > 0) { menuClient = await _menuRepository.GetAsync(input.Id.Value); } var output = new GetMenuClientOutput(); output.MenuClient = menuClient != null ? ObjectMapper.Map <MenuClientDto>(menuClient) : new MenuClientDto(); var parentMenuId = output.MenuClient.ParentId ?? 0; output.MenuClients = await _menuRepository.GetAll() .Where(m => m.Status) .Select(c => new ComboboxItemDto(c.Id.ToString(), c.Name) { IsSelected = parentMenuId == c.Id }) .ToListAsync(); return(output); }
//This method along with the AssignUserRole were just loose functions in the create method but we have extracted the to //reduce method bloat...which to be honest just makes things hard to read. This keeps things in a very obvious grouping. private string AssignName() { MenuClient <string> userStringClient = new MenuClient <string>(); userStringClient.Prompt = "Enter User name"; return(userStringClient.GetUserInput()); }
static void Main() { var users = new MenuClient().GetUsers(); foreach (var user in users) { Test(user.UID); } // Calculator c =new Calculator(null,new MenuClient()); // var nextWeekMenu = new Calculator(null, new MenuClient()).GetNextWeekMenu(); // var startDate = new DateTime(2017, 2, 01); // var endDate = new DateTime(2017, 3, 10); // var userId = "ecefda4d-0a1e-11e7-946d-00155d400817"; // var userMenues = new MenuClient().GetUserMenus(userId, startDate, endDate).ToList(); // var pastWeekMenus = new Calculator(null, new MenuClient()).GetLastThreeWeekMenus().ToList(); // Predict p = new Predict(nextWeekMenu, userMenues, pastWeekMenus); //var pred = p.Generate(); // var menuClient =new MenuClient(); // menuClient.CreateProductAsync(pred.MenuPredictionList, userId); // List<MenuPrediction> predictions = new List<MenuPrediction>(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
public async Task <MenuClientDto> CreateMenuClientAsync(CreateMenuClientInput input) { MenuClient entity = ObjectMapper.Map <MenuClient>(input); entity = await _menuRepository.InsertAsync(entity); return(ObjectMapper.Map <MenuClientDto>(entity)); }
private IEnumerable <WxMenuDto> GetMenusByParentId(string menuId, MenuClient clientType) { var menus = _menuRepo.Query(p => p.ParentId == menuId && p.Client == clientType).ToList(); foreach (var menu in menus) { yield return(_mapper.Map <WxMenuDto>(menu)); } }
public async Task DeleteMenuClientAsync(EntityDto <int> input) { MenuClient entity = await _menuRepository.GetAsync(input.Id); //Tạm thời hiểu status là field dể check record đó có dc xóa hay ko //Để biết thêm chi tiết liên hệ với Thức :D entity.Status = false; _ = await _menuRepository.UpdateAsync(entity); await CurrentUnitOfWork.SaveChangesAsync(); }
public User Select() { //We create an instance of our own MenuClient<T> object that I've enabled for use //Any object may be assigned to the MenuClientConstructer call like this. MenuClient <User> userMenu = new MenuClient <User>(); userMenu.Prompt = "Select a User"; userMenu.Selections = Contents; return(userMenu.GetUserSelection()); }
private UserRole AssignUserRole() { MenuClient <UserRole> userRoleClient = new MenuClient <UserRole>(); userRoleClient.Prompt = "What shall be your role?"; foreach (UserRole roleKey in Enum.GetValues(typeof(UserRole)).Cast <UserRole>().ToList <UserRole>()) { userRoleClient.Selections.Add(roleKey); } return(userRoleClient.GetUserSelection()); }
public async Task <MenuClientDto> UpdateMenuClientAsync(UpdateMenuClientInput input) { MenuClient entity = await _menuRepository.GetAsync(input.Id); ObjectMapper.Map(input, entity); entity = await _menuRepository.UpdateAsync(entity); await CurrentUnitOfWork.SaveChangesAsync(); return(ObjectMapper.Map <MenuClientDto>(entity)); }
private void PopulateUsersListBox() { var users = new MenuClient().GetUsers(); if (users != null) { foreach (var user in users) { listBoxUsers.Items.Add(user); } } }
private IList <WxMenuDto> GetInitMenus(MenuClient clientType) { IList <WxMenuDto> topMenus = this.GetTopMenus(clientType).ToList(); foreach (var info in topMenus) { info.Chilren = this.GetMenusByParentId(info.Id, clientType).ToList(); if (info.Chilren == null) { info.Chilren = new List <WxMenuDto>(); } } return(topMenus); }
private string AssignPassword() { MenuClient <string> userStringClient = new MenuClient <string>(); userStringClient.Prompt = "Password"; bool passwordValid = false; string userPassword; while (!passwordValid) { userPassword = userStringClient.GetUserInput(); if (userPassword.Count() >= 8) { passwordValid = true; } return(userPassword); } throw new Exception("Password Invalid"); }
private static void Test(string userId) { Calculator c = new Calculator(null, new MenuClient()); var nextWeekMenu = new Calculator(null, new MenuClient()).GetNextWeekMenu(); var startDate = new DateTime(2017, 2, 01); var endDate = new DateTime(2017, 3, 10); //var userId = "ecefda4d-0a1e-11e7-946d-00155d400817"; var userMenues = new MenuClient().GetUserMenus(userId, startDate, endDate).ToList(); var pastWeekMenus = new Calculator(null, new MenuClient()).GetLastThreeWeekMenus().ToList(); Predict p = new Predict(nextWeekMenu, userMenues, pastWeekMenus); var pred = p.Generate(); var menuClient = new MenuClient(); menuClient.CreateProductAsync(pred.MenuPredictionList, userId); }
public WXMPClient( string appId, TicketClient ticketClient, BasisServiceClient basisServiceClient, CustomServiceClient customServiceClient, TemplateServiceClient templateServiceClient, MenuClient menuClient, UserManagerClient userManagerClient, AccountManagerClient accountManagerClient, MaterialClient materialClient, AccessTokenManager tokenManager) { AppId = appId; TicketClient = ticketClient; BasisServiceClient = basisServiceClient; CustomServiceClient = customServiceClient; TemplateServiceClient = templateServiceClient; MenuClient = menuClient; UserManagerClient = userManagerClient; AccountManagerClient = accountManagerClient; MaterialClient = materialClient; TokenManager = tokenManager; }
public override void Create() { MenuClient <string> userNameClient = new MenuClient <string>(); userNameClient.Prompt = "User name"; string userName = userNameClient.GetUserInput(); MenuClient <UserRole> userRoleClient = new MenuClient <UserRole>(); userRoleClient.Prompt = "What is your role?"; foreach (UserRole role in Enum.GetValues(typeof(UserRole)).Cast <UserRole>().ToList <UserRole>()) { userRoleClient.Selections.Add(role); } UserRole userRole = userRoleClient.GetUserSelection(); MenuClient <string> userPasswordClient = new MenuClient <string>() { Prompt = "Password" }; string userPassword = userPasswordClient.GetUserInput(); User newUser = new User(userName, userRole, userPassword); Contents.Add(newUser); Current = newUser; }
public Calculator(User user, MenuClient menuClient) { _user = user; _menuClient = menuClient; }
private void btnGetWeekMenu_Click(object sender, EventArgs e) { var weekMenu = new MenuClient().GetWeekMenu(dateTimePicker1.Value); }
private IEnumerable <WxMenuDto> GetTopMenus(MenuClient clientType) { return(GetMenusByParentId(null, clientType)); }
private void button1_Click(object sender, EventArgs e) { var userMenues = new MenuClient().GetUserMenus(txtUID.Text, dateTimePicker2.Value, dateTimePicker3.Value); }
//Main Method public static void Main() { //bool for continuing the program bool pleaseContinue = true; //string reply for what the user inputs string reply = ""; //a do-while loop for the menu do { //using a method to display the menu DisplayMenu(); //getting input from the user using a method reply = Input(); //a switch case for the menu switch (reply) { //case 1 for the NoClient menu case "1": //clearing the screen with a method that was created ClearScreen(); //calling the NoClient's main method for its menu NoClient.NoClientMain(); //breaking from the case break; //case 2 for the MenuClientMain case "2": //clearing the screen with a method that was created ClearScreen(); //calling the MenuClient's main method for its menu MenuClient.MenuClientMain(); //breaking from the case break; //case 3 for the FormClient case "3": //clearing the screen with a method that was created ClearScreen(); //have a try and catch here because if the user wants to //get the form again after it has runned, an exception happens //which is a InvalidOperationException. try { //enabling visual styles Application.EnableVisualStyles(); //setting compatibility with text rendering //you can only do this once in the program. //That's why there is a try catch block. Application.SetCompatibleTextRenderingDefault(false); //run the form Application.Run(new AK_One.FormClient()); } catch (InvalidOperationException) { //run the form again if the user has selected to run the form in //the menu more than once Application.Run(new AK_One.FormClient()); } //breaking from the case break; //This case 4 is the exit case "4": //clearing the screen with a method that was created ClearScreen(); //setting the bool to false to let the loop know to exit pleaseContinue = false; //logging that the user exited the menu. Utilities.LogIt("Program::The user exited the program menu.\n", Utilities.MessageSeverity.INFORMATIONAL, true); //breaking from the case break; //default case default: //clearing the screen with a method that was created ClearScreen(); //try to throw a new exception try { //throwing my custom exception throw new CustomExceptions(); } //catching the exception catch (CustomExceptions) { //logging the exception Utilities.LogIt("You entered an invalid option in the main menu!\nTry again!\n", Utilities.MessageSeverity.ERROR, true); } //breaking from the case break; }//end of switch case //end of while loop if pleaseContinue is false } while (pleaseContinue); }//end of main method
private void btnGetReceipes_Click(object sender, EventArgs e) { var recipes = new MenuClient().GetRecipes(); }