private void addExpense() { bool validInput = true; if (expenseAmount.Value < 0) { validInput = false; // error here } if (expenseNameTextBox.Text == "") { validInput = false; // error here } if (expenseNameTextBox.Text != this.expenseNameTextBox.Text || expenseAmount.Value != this.expenseDetails.getAmount()) { // update or insertS if (validInput) { controller = new ExpenseModule(Util.CONNECTION_DETAILS.CONNECITION_STRING, ""); this.expenseDetails.setExpenseName(expenseNameTextBox.Text); this.expenseDetails.setAmount((int)expenseAmount.Value); controller.addExpense(this.expenseDetails); //controller.addExpense() } } }
public async Task <IActionResult> EditController(int id, [Bind("Id,FG_Code,SerialNumber,AuthenticationCode,FirmwareVersion,SoftwareVersion,RecipeVersion,Skins,Wallpaper,SevenDayTimer,SleepDelay,ControllerDate,Status" + "RemoteKill,IsDeleted,ModifiedBy,CreatedBy")] ControllerModule controllerModule) { if (id != controllerModule.Id) { return(NotFound()); } if (ModelState.IsValid) { try { var user = _userManager.GetUserId(User); // var userName = _context.Users.Where(x => x.Id == user).Select(x => x.FirstName + " " + x.LastName).FirstOrDefault(); var userName = _context.Users.Where(x => x.Id == user).Select(x => x.Id).FirstOrDefault(); controllerModule.ModifiedBy = userName; _context.Update(controllerModule); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ControllerModuleExists(controllerModule.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(ControllersList))); } return(View(controllerModule)); }
static void Main(string[] args) { // Template generators are used to render templates // (convert code + html to pure html). TemplateManager mgr = new TemplateManager(); mgr.Add("haml", new HamlGenerator()); // The httpserver is quite dumb and will only serve http, nothing else. HttpServer server = new HttpServer(); // a controller mode implements a MVC pattern // You'll add all controllers to the same module. ControllerModule mod = new ControllerModule(); mod.Add(new UserController(mgr)); server.Add(mod); // file module will be handling files FileModule fh = new FileModule("/", Environment.CurrentDirectory); fh.AddDefaultMimeTypes(); server.Add(fh); // Let's start pure HTTP, we can also start a HTTPS listener. server.Start(IPAddress.Any, 8081); Console.ReadLine(); }
public void Update() { _updateStopwatch.Restart(); try { if (commands == null) { commands = new ICommand[OutputCount]; } _outputMediator.LockOutputs(); for (int i = 0; i < OutputCount; i++) { commands[i] = GenerateOutputCommand(Outputs[i]); } ControllerModule.UpdateState(0, commands); } catch (Exception e) { Logging.Error(e, "An error ocuered outputing data for controller {0}", Name); } finally { _outputMediator.UnlockOutputs(); } _updateTimeValue.Set(_updateStopwatch.ElapsedMilliseconds); _updateStopwatch.Stop(); }
public void StartTutorial() { // load language from a YAML file. new YamlWatcher(_language, "..\\..\\tutorial5\\language.yaml"); // "..\\..\\" since we run the tutorial in vstudio Validator.Language = _language.GetChild("Validator") ?? LanguageNode.Empty; // since we do not use files on disk, we'll just add the resource template loader. ResourceTemplateLoader templateLoader = new ResourceTemplateLoader(); templateLoader.LoadTemplates("/", Assembly.GetExecutingAssembly(), "Tutorial.Tutorial5.views"); TemplateManager templateManager = new TemplateManager(templateLoader); templateManager.AddType(typeof(WebHelper)); templateManager.Add("haml", new HamlGenerator()); // we've just one controller. Add it. ControllerModule controllerModule = new ControllerModule(); controllerModule.Add(new UserController(templateManager, _language)); _server.Add(controllerModule); // add file module, to be able to handle files ResourceFileModule fileModule = new ResourceFileModule(); fileModule.AddResources("/", Assembly.GetExecutingAssembly(), "Tutorial.Tutorial5.public"); _server.Add(fileModule); // ok. We should be done. Start the server. _server.Start(IPAddress.Any, 8081); Console.WriteLine("Tutorial 5 is running. Go to http://localhost:8081/user/"); Console.WriteLine("Try to add '?lcid=1053' and '?lcid=1033' to address to switch language (i.e: http://localhost:8081/user/?lcid=1053)."); }
// clicking create building private void SignupAsAdminButton_Click(object sender, EventArgs e) { controller = new CreateAndJoinBuilding(Util.CONNECTION_DETAILS.CONNECITION_STRING, buildingsTableName); this.apartment = new Building(buildingNameTextbox.Text, Convert.ToInt32(noOfFloorsInput.Value), Convert.ToInt32(flatsPerFloorInput.Value), codeTextBox.Text, user, Convert.ToInt32(flatNoFormatInput.Value), (int)balanceInput.Value); controller.createBuilding(apartment, this, user, Convert.ToInt32(adminFlatInput.Value)); }
public void StartTutorial() { // load language from a YAML file. new YamlWatcher(_language, "..\\..\\tutorial5\\language.yaml"); // "..\\..\\" since we run the tutorial in vstudio Validator.Language = _language.GetChild("Validator") ?? LanguageNode.Empty; // since we do not use files on disk, we'll just add the resource template loader. ResourceTemplateLoader templateLoader = new ResourceTemplateLoader(); templateLoader.LoadTemplates("/", Assembly.GetExecutingAssembly(), "Tutorial.Tutorial5.views"); TemplateManager templateManager = new TemplateManager(templateLoader); templateManager.AddType(typeof (WebHelper)); templateManager.Add("haml", new HamlGenerator()); // we've just one controller. Add it. ControllerModule controllerModule = new ControllerModule(); controllerModule.Add(new UserController(templateManager, _language)); _server.Add(controllerModule); // add file module, to be able to handle files ResourceFileModule fileModule = new ResourceFileModule(); fileModule.AddResources("/", Assembly.GetExecutingAssembly(), "Tutorial.Tutorial5.public"); _server.Add(fileModule); // ok. We should be done. Start the server. _server.Start(IPAddress.Any, 8081); Console.WriteLine("Tutorial 5 is running. Go to http://localhost:8081/user/"); Console.WriteLine("Try to add '?lcid=1053' and '?lcid=1033' to address to switch language (i.e: http://localhost:8081/user/?lcid=1053)."); }
private void deleteExpense() { if (user.getFlat().getIsManager() >= 2) { controller = new ExpenseModule(Util.CONNECTION_DETAILS.CONNECITION_STRING, ""); controller.deleteExpense(this.GetExpenseDetails()); this.Dispose(); } }
private void confirmButton_Click(object sender, EventArgs e) { controller = new ExpenseModule(Util.CONNECTION_DETAILS.CONNECITION_STRING, ""); controller.confirmPayment(this.expenseTransaction, this.expense); controller = new MainScreenController(Util.CONNECTION_DETAILS.CONNECITION_STRING, ""); controller.updateBalance(this.expense.GetExpenseDetails().getApartment(), this.mainView); this.Dispose(); }
private void addExpenseButton_Click(object sender, EventArgs e) { if (user.getFlat().getIsManager() >= 3) { this.addExpense(); controller = new ExpenseModule(Util.CONNECTION_DETAILS.CONNECITION_STRING, ""); controller.addExpense(this, regularActive, expenses.Last().GetExpenseDetails()); } }
public Receipt(Flat flat, string month) // used for showing { InitializeComponent(); // receiptMonthBox.Items.AddRange(new object[] { "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER" }); controller = new TransactionModule(Util.CONNECTION_DETAILS.CONNECITION_STRING, Util.Tables.TABLE_INCOMING_TRANSACTIONS.TABLE_NAME); controller.showPaidReceipt(this, month, flat.getFlatNumber()); }
public ControllerModuleTest() { _controller = new TestController(); _request = new HttpTestRequest { HttpVersion = "HTTP/1.1" }; _context = new HttpResponseContext(); _response = _request.CreateResponse(_context); _module = new ControllerModule(); }
private void SettingButton_Click(object sender, EventArgs e) { if (user.getFlat().getIsManager() == 3) // only admin can click settings button { Color defaultColor = Color.Gainsboro; detailsName.ReadOnly = settingActivated; detailsMaintanance.ReadOnly = settingActivated; detailsEmail.ReadOnly = settingActivated; detailsMobile.ReadOnly = settingActivated; managerButton.Visible = !settingActivated; switchlabel.Visible = !settingActivated; if (!settingActivated) { SettingButton.ButtonText = "OK"; detailsName.BackColor = Color.White; detailsMaintanance.BackColor = Color.White; detailsEmail.BackColor = Color.White; detailsMobile.BackColor = Color.White; prevFee = Convert.ToInt32(detailsMaintanance.Text); prevDues = Convert.ToInt32(detailsDues.Text); } else // update flat { SettingButton.ButtonText = "Settings"; detailsName.BackColor = defaultColor; detailsMaintanance.BackColor = defaultColor; detailsEmail.BackColor = defaultColor; detailsMobile.BackColor = defaultColor; controller = new MainScreenController(Util.CONNECTION_DETAILS.CONNECITION_STRING, flatTableName); int newFee, newDues; if (prevFee != Convert.ToInt32(detailsMaintanance.Text)) { newFee = Convert.ToInt32(detailsMaintanance.Text); newDues = newFee + prevDues; } else { newFee = prevFee; newDues = prevDues; } Flat flat = new Flat(Convert.ToInt32(detailsFlatNumber.Text), detailsName.Text, detailsEmail.Text, detailsMobile.Text, newDues, newFee, 1, this.apartment); detailsDues.Text = flat.getDues().ToString(); controller.updateDetailsPanel(flat); apartment.updateFlatAt(flat); floors.ElementAt((flat.getFlatNumber() / 100) - 1).getFlatAt((flat.getFlatNumber() % 100) - 1).updatePaidStatus(); } settingActivated = !settingActivated; } }
public Receipt(User user, Flat flat, Building apartment, string month, int year, MainScreen mainScreen, Income incomeView) // used for collection { InitializeComponent(); setValues(flat, month, year); controller = new TransactionModule(Util.CONNECTION_DETAILS.CONNECITION_STRING, Util.Tables.TABLE_INCOMING_TRANSACTIONS.TABLE_NAME); transaction = new IncomingTransaction(receiptTrID.Text, apartment, flat, (int)receiptAmount.Value, reciptDateTime.Value, user.getFlat(), month, year); this.mainScreen = mainScreen; this.apartment = apartment; this.incomeView = incomeView; }
public void BindWithModelTest() { ModelEmulator model = new ModelEmulator(); Controller controller = new ControllerModule(); controller.BindWithModel(model); controller.StartWork(); bool isTestPassed = model.IsTestPassed; Assert.IsTrue(isTestPassed); }
public void BindWithViewTest() { ActivateTestView viewEmulator = new ActivateTestView(); Controller controller = new ControllerModule(); controller.BindWithView(viewEmulator); controller.Activate(); bool isTestPassed = viewEmulator.IsTestPassed; Assert.IsTrue(isTestPassed); }
private void confirmButton1_Click_1(object sender, EventArgs e) { controller = new TransactionModule(Util.CONNECTION_DETAILS.CONNECITION_STRING, Util.Tables.TABLE_INCOMING_TRANSACTIONS.TABLE_NAME); controller.confirmTransaction(this.transaction, this.apartment, this.incomeView); controller = new MainScreenController(Util.CONNECTION_DETAILS.CONNECITION_STRING, Util.Tables.TABLE_FLATS.TBL_FLATS); controller.showDetailsPanel(this.transaction.getPaidBy(), (Income)this.Parent); controller.updateBalance(this.apartment, this.mainScreen); this.Dispose(); // receiptpanel1.Visible = false; }
public void setMonths(List <string> months) { this.months.AddRange(months.ToArray()); string currentMonth = miscFunctions.ToMonthName(DateTime.Now).ToUpper(); if (!this.months.Contains(currentMonth)) { this.months.Add(currentMonth); controller = new MainScreenController(Util.CONNECTION_DETAILS.CONNECITION_STRING, ""); controller.newMonthStarted(this.apartment); } }
public void setYears(List <string> years) { this.years.AddRange(years); string currentYear = DateTime.Now.Year.ToString(); if (!this.years.Contains(currentYear)) { this.years.Add(currentYear); controller = new MainScreenController(Util.CONNECTION_DETAILS.CONNECITION_STRING, ""); controller.newMonthStarted(this.apartment); } // increment dues controller.setMonths(this, 2019, this.apartment); }
public async Task <IActionResult> CreateController([Bind("Id,FG_Code,SerialNumber,AuthenticationCode,FirmwareVersion,SoftwareVersion,RecipeVersion,Skins," + "Wallpaper,SevenDayTimer,SleepDelay,ControllerDate,Status,RemoteKill,IsDeleted,ModifiedBy,CreatedBy")] ControllerModule controllerModule) { if (ModelState.IsValid) { var user = _userManager.GetUserId(User); // var userName = _context.Users.Where(x => x.Id == user).Select(x => x.FirstName + " " + x.LastName).FirstOrDefault(); var userName = _context.Users.Where(x => x.Id == user).Select(x => x.Id).FirstOrDefault(); controllerModule.CreatedBy = userName; _context.Add(controllerModule); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(ControllersList))); } return(View(controllerModule)); }
public MainScreen(User user, Building apartment) { InitializeComponent(); this.main.AutoScroll = false; this.main.AutoScroll = true; this.user = user; this.apartment = apartment; months = new List <string>(); years = new List <String>(); updateMainScreen(); controller = new MainScreenController(Util.CONNECTION_DETAILS.CONNECITION_STRING, ""); controller.updateBalance(apartment, this); // calling controller function and creating user controller = new TransactionModule(Util.CONNECTION_DETAILS.CONNECITION_STRING, ""); controller.setYears(this, this.apartment); }
public void Update() { _updateStopwatch.Restart(); try { if (commands == null) { commands = new ICommand[OutputCount]; } _outputMediator.LockOutputs(); if (OutputCount > 15000) { Parallel.For(0, OutputCount, _parallelOptions, () => ControllerModule.DataPolicyFactory.CreateDataPolicy(), (x, loopState, dataPolicy) => { var o = Outputs[x].State; commands[x] = o?.Value != null ? dataPolicy.GenerateCommand(o) : null; return(dataPolicy); }, x => { }); //nothing to do but let the datapolicy expire } else { for (int x = 0; x < OutputCount; x++) { var o = Outputs[x].State; commands[x] = o?.Value != null?_dataPolicy.GenerateCommand(o) : null; } } ControllerModule.UpdateState(0, commands); } catch (Exception e) { Logging.Error(e, "An error occurred outputting data for controller {0}", Name); } finally { _outputMediator.UnlockOutputs(); } _updateTimeValue.Set(_updateStopwatch.ElapsedMilliseconds); _updateStopwatch.Stop(); }
private void monthComboBox_SelectedIndexChanged(object sender, EventArgs e) { /* foreach (ExpenseCard exp in expenses) * { * if (exp.GetExpenseDetails().getMonth().ToUpper() == monthComboBox.SelectedItem.ToString().ToUpper()) * exp.Show(); * * else * exp.Hide(); * }*/ controller = new ExpenseModule(CONNECTION_DETAILS.CONNECITION_STRING, ""); controller.getAllExpense(this.expenses, this.apartment, monthComboBox.SelectedItem.ToString(), Convert.ToInt32(yearComboBox.SelectedItem)); foreach (ExpenseCard exp in expenses) { exp.setView(this.mainView); if (exp.GetExpenseDetails().GetExpenseType() == ExpenseType.Regular) { expensesList.Controls.Add(exp); if (exp.GetExpenseDetails().GetExpenseStatus() == ExpenseStatus.Paid) { exp.SendToBack(); } else { exp.BringToFront(); } } else { otherExpensesList.Controls.Add(exp); if (exp.GetExpenseDetails().GetExpenseStatus() == ExpenseStatus.Paid) { exp.SendToBack(); } else { exp.BringToFront(); } } } }
public Expense(User user, Building apartment, MainScreen mainView) : this() // will be used for regular expenses { this.user = user; this.mainView = mainView; expensesList.Visible = true; otherExpensesList.Visible = false; otherExpensesList.Location = expensesList.Location; this.apartment = apartment; this.setYears(mainView.getYears()); this.setMonths(mainView.getMonths()); controller = new ExpenseModule(CONNECTION_DETAILS.CONNECITION_STRING, ""); controller.getAllExpense(this.expenses, this.apartment, monthComboBox.SelectedItem.ToString(), Convert.ToInt32(yearComboBox.SelectedItem)); foreach (ExpenseCard exp in expenses) { exp.setView(this.mainView); if (exp.GetExpenseDetails().GetExpenseType() == ExpenseType.Regular) { expensesList.Controls.Add(exp); if (exp.GetExpenseDetails().GetExpenseStatus() == ExpenseStatus.Paid) { exp.SendToBack(); } else { exp.BringToFront(); } } else { otherExpensesList.Controls.Add(exp); if (exp.GetExpenseDetails().GetExpenseStatus() == ExpenseStatus.Paid) { exp.SendToBack(); } else { exp.BringToFront(); } } } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder()); var cultureInfo = new CultureInfo("en-US"); cultureInfo.NumberFormat.NumberDecimalSeparator = "."; CultureInfo.DefaultThreadCurrentCulture = cultureInfo; CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); Mapper.Initialize(cfg => AutoMapperConfiguration.Configure(cfg) ); ServiceModule service = new ServiceModule("DefaultConnection"); ControllerModule controller = new ControllerModule(); var kernel = new StandardKernel(service, controller); DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel)); ModelValidatorProviders.Providers.Clear(); //FluentValidationModelValidatorProvider.Configure(provider => provider.AddImplicitRequiredValidator = false); }
private void loginButton_Click(object sender, EventArgs e) { controller = new Controller.AuthorizationModule(Util.CONNECTION_DETAILS.CONNECITION_STRING, usersTableName); controller.signIn(this.user, this, loginEmailTextbox.Text, loginPasswordTextbox.Text, apartment); }
private void MakeAMemberButton_Click(object sender, EventArgs e) { controller = new CreateAndJoinBuilding(Util.CONNECTION_DETAILS.CONNECITION_STRING, ""); controller.joinApartment(apartmentIDTextbox.Text, membersixdigitcodetextBox.Text, this); }
private void joinApartmentButton_Click(object sender, EventArgs e) { controller = new CreateAndJoinBuilding(Util.CONNECTION_DETAILS.CONNECITION_STRING, ""); controller.joinFlat(this.user, this, apartmentIDTextbox.Text, this.apartment, Convert.ToInt32(chooseFlatNumber.SelectedItem)); }
private void signUpButton_Click(object sender, EventArgs e) { // add validations here, emailFormat, Minimum Password Length, all text boxes checked string format = "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$"; if (firstNameTextBox.Text == "" || lastNameTextBox.Text == "" || emailTextBox.Text == "" || mobileTextBox.Text == "" || passwordTextBox.Text == "" || confirmPasswordTextBox.Text == "" || (memebrRadio.Checked != true && adminRadio.Checked != true)) { if (firstNameTextBox.Text == "") { errorProvider1.SetError(this.firstNameTextBox, "Please provide first name"); firstNameTextBox.Focus(); } else { errorProvider1.Clear(); } } { if (lastNameTextBox.Text == "") { errorProvider2.SetError(this.lastNameTextBox, "Please provide last name"); } else { errorProvider2.Clear(); } if (firstNameTextBox.Text != "" && lastNameTextBox.Text == "") { lastNameTextBox.Focus(); } } { if (emailTextBox.Text == "") { errorProvider3.SetError(this.emailTextBox, "Please provide email"); } else { errorProvider3.Clear(); } if (firstNameTextBox.Text != "" && lastNameTextBox.Text != "" && emailTextBox.Text == "") { emailTextBox.Focus(); } } { if (mobileTextBox.Text == "" || mobileTextBox.Text.Length != 11) { errorProvider4.SetError(this.mobileTextBox, "Please provide mobie number"); } else { errorProvider4.Clear(); } if (firstNameTextBox.Text != "" && lastNameTextBox.Text != "" && emailTextBox.Text != "" && mobileTextBox.Text == "") { mobileTextBox.Focus(); } } { if (passwordTextBox.Text == "") { errorProvider6.SetError(this.passwordTextBox, "Please set password"); } else { errorProvider6.Clear(); } if (firstNameTextBox.Text != "" && lastNameTextBox.Text != "" && emailTextBox.Text != "" && mobileTextBox.Text != "" && passwordTextBox.Text == "") { passwordTextBox.Focus(); } } { if (confirmPasswordTextBox.Text == "") { errorProvider7.SetError(this.confirmPasswordTextBox, "Please confirm your password"); } else { errorProvider7.Clear(); } if (firstNameTextBox.Text != "" && lastNameTextBox.Text != "" && emailTextBox.Text != "" && mobileTextBox.Text != "" && passwordTextBox.Text != "" && confirmPasswordTextBox.Text == "") { confirmPasswordTextBox.Focus(); } } { if (adminRadio.Checked != true && memebrRadio.Checked != true) { errorProvider5.SetError(this.memebrRadio, "Please select one"); } else { errorProvider5.Clear(); } if (firstNameTextBox.Text != "" && lastNameTextBox.Text != "" && emailTextBox.Text != "" && mobileTextBox.Text != "" && passwordTextBox.Text != "" && confirmPasswordTextBox.Text != "" && (adminRadio.Checked != true && memebrRadio.Checked != true)) { memebrRadio.Focus(); } } if (Regex.IsMatch(emailTextBox.Text, format)) { errorProvider1.Clear(); emailTextBox.Focus(); } else { errorProvider1.SetError(this.emailTextBox, "Please provide valid email"); return; } if (mobileTextBox.Text.Length <= 10 || mobileTextBox.Text.Length >= 12) { //errorProvider1.Clear(); errorProvider4.SetError(this.mobileTextBox, "Please provide valid mobile number"); // mobileTextBox.Focus(); } else { errorProvider4.Clear(); } if (passwordTextBox.Text != confirmPasswordTextBox.Text) { confirmPasswordError.Visible = true; confirmPasswordTextBox.Text = ""; confirmPasswordTextBox.Focus(); } else { controller = new Controller.AuthorizationModule(Util.CONNECTION_DETAILS.CONNECITION_STRING, usersTableName); user = new User(firstNameTextBox.Text, lastNameTextBox.Text, emailTextBox.Text, passwordTextBox.Text, adminRadio.Checked, mobileTextBox.Text); controller.signUp(user, this); } }
public ReportDialogBox(Building apartment) : this() { this.apartment = apartment; controller = new ReportModule(Util.CONNECTION_DETAILS.CONNECITION_STRING); controller.setMonthAndYears(this, apartment); }
private void okButton_Click(object sender, EventArgs e) { controller = new ReportModule(Util.CONNECTION_DETAILS.CONNECITION_STRING); controller.generateReprt(this, this.apartment, 7, 2019); }