protected void FillPage() { LinkedList <Item> list = new LinkedList <Item>(); if (!IsPostBack) { list = ConnectionClass.GetAllTabletByType(); } else { list = ConnectionClass.GetTabletByType(DropDownList1.SelectedValue); } /* * string sb = ""; * foreach (Item d in list) * { * sb += @"<table class='desktopTable'>" + * "<tr><th rowspan='3' width='150px'><a href='/Buy.aspx?id=" + d.ID + "'><img runat='server' src='" + d.Image + "' /></a></th>" + * "<th width='50px'>Name: </td><td>" + d.Type + " " + d.Name + "</td>" + * "<th rowspan='3' width='50px'>" + * "<button type='button' onclick='redirect(" + d.ID + ")' name='buy' value='" + d.ID + "' class='css3button'>buy</button>" + * "</th></tr><tr><th>Price: </th><td>" + d.Price + " $</td></tr>" + * "<tr><th>Description: </th><td>" + d.Description + "</td></tr></table>"; * } */ lblOutput.Text = LogicClass.GetTabletProducts(list); }
// GET: bills public ActionResult Index() { int iid = Convert.ToInt16(Session["Hid"]); List <bills> bil = db.bill.ToList().FindAll(x => x.homeid == iid); LogicClass lg = new LogicClass(); if (bil.Count().Equals(0)) { bills b = new bills(); b.homeid = iid; b.waterCost = Math.Round(lg.getRandom(500, 1000), 2, MidpointRounding.AwayFromZero); b.electricCost = Math.Round(lg.getRandom(500, 15000), 2, MidpointRounding.AwayFromZero); db.bill.Add(b); db.SaveChanges(); List <bills> bi = db.bill.ToList().FindAll(x => x.homeid == iid); return(View(bi)); } foreach (var item in bil) { if (item.waterCost.Equals(0) && item.electricCost.Equals(0)) { item.electricCost = Math.Round(lg.getRandom(500, 1000), 2, MidpointRounding.AwayFromZero); item.waterCost = Math.Round(lg.getRandom(500, 1500), 2, MidpointRounding.AwayFromZero); db.SaveChanges(); } } return(View(bil)); }
static void Main(string[] args) { // string reverseStr = LogicClass.ReverseStr("Hello"); // Console.WriteLine(reverseStr); // Calling Swap - call by value //int x = 10, y = 20; //int x, y; //Console.WriteLine($" Before Swapping x={x} and y={y}"); // LogicClass.Swap(out int x,out int y); // Console.WriteLine($" after Swapping x={x} and y={y}"); //multi values fields - can hold upto 8 items /*Tuple<int, int, string, char, char> tpl = * new Tuple<int, int, string,char,char>(1, 2, "test",'A','B'); * var item = tpl.Item3; * Console.WriteLine(item);*/ var x = "54"; var y = "89"; Console.WriteLine($" Before Swapping x={x} and y={y}"); LogicClass <string> .Swap <string>(ref x, ref y); Console.WriteLine($" after Swapping x={x} and y={y}"); }
public ActionResult Index(string sortOrder) { var output = mapping.MappLibraryItemToVM(LibraryItemProcessor.LoadLibraryItem()); output = LogicClass.SetAcronym(output); if (sortOrder == null && Session["sortOrderSession"] != null) { sortOrder = Session["sortOrderSession"].ToString(); } switch (sortOrder) { case "type": Session["sortOrderSession"] = sortOrder; ViewBag.orderState = "type"; return(View(output.OrderBy(x => x.Type))); case "category": Session["sortOrderSession"] = null; ViewBag.orderState = "category"; return(View(output.OrderBy(x => x.Category.CategoryName))); default: return(View(output.OrderBy(x => x.Category.CategoryName))); } }
public ActionResult paybills() { LogicClass lg = new LogicClass(); double el = lg.getRandom(0, 15000); ViewBag.outt = el; return(View()); }
public void Init() { this.l = new LogicClass(); this.r = new Repo(); this.userLista = new List <User>(); this.contentLista = new List <Content>(); this.l.UserManagement.Registration("Teszt", "jelszo"); }
private LogicClass A() { if (this.abP == null && !string.IsNullOrEmpty(this.abo)) { this.abP = LogicSystemManager.Instance.MapClassManager.GetByName(this.abo); } return(this.abP); }
//Button for Unlocking --------------------------------------------------------------------------------------------- private void btn_UnLock_Click(object sender, EventArgs e) { try { DataAccessClass dac = new DataAccessClass(); Boolean bl = dac.PassKey(txt_Pass.Text); if (bl) { DirectoryInfo d = new DirectoryInfo(fpath); //string selectedpath = d.Parent.FullName + d.Name; if (fpath.LastIndexOf(".{") == -1) { MessageBox.Show("Folder IS Already Unlocked", "NO NEED", MessageBoxButtons.OK); } else { d.MoveTo(fpath.Substring(0, fpath.LastIndexOf("."))); } //string filename = fpath.ToString(); //txtFilePath.Text = txtFilePath.Text.Substring(0, txtFilePath.Text.LastIndexOf(".")); pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\unlock.jpg"); MessageBox.Show("Folder has been UnLocked!", "Congratulations!", MessageBoxButtons.OK); string[] files = Directory.GetFiles(txt_FolderPath.Text, "*.*", SearchOption.AllDirectories); //Console.WriteLine("The number of directories starting with p is {0}.", folders.Length); MessageBox.Show("There Are " + files.Length + " files in the diretory....", "Nice!!", MessageBoxButtons.OK); int count = 0; foreach (string file in files) { LogicClass lgCs = new LogicClass(); Boolean s = lgCs.DecryptingMethod(file); if (s) { count++; } } if (count == files.Length) { MessageBox.Show(count + " Files Have been Unlocked!!", "Congratzz!!", MessageBoxButtons.OK); } else { MessageBox.Show("The Folder Has not Unlocked Properly!", "Error", MessageBoxButtons.OK); } DataAccessClass ndc = new DataAccessClass(); ndc.DeleteHighFolder(txt_FolderPath.Text); txt_FolderPath.Clear(); txt_Pass.Clear(); } } catch (Exception ex) { MessageBox.Show("Invalid Input...", "Error!", MessageBoxButtons.OK); } }
public async Task <ActionResult> Register(RegisterViewModel model, HttpPostedFile file) { LogicClass lg = new LogicClass(); if (ModelState.IsValid && file.ContentLength > 0) { ApplicationUser user = new ApplicationUser(); var filelength = file.ContentLength; byte[] imageBytes = new byte[filelength]; file.InputStream.Read(imageBytes, 0, filelength); user.UserName = model.Email; user.Email = model.Email; user.gender = model.gender; user.fname = model.fname; user.lname = model.lname; user.race = model.race; user.mstatus = model.mstatus; user.idno = model.idno; user.age = lg.calcAge(); user.Uimg = imageBytes; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); Client cl = new Client { userID = user.Id, fname = model.fname, lname = model.lname, race = model.race, age = model.age, mstatus = model.mstatus, idno = Convert.ToInt64(model.idno), gender = model.gender }; db.clients.Add(cl); db.SaveChanges(); return(RedirectToAction("Index", "Residences")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
//Does The Encryption private void button_LockEncr_Click(object sender, EventArgs e) { try { DataAccessClass dt = new DataAccessClass(); //DataAccessClass dt = new DataAccessClass(); //DataAccessClass dt2 = new DataAccessClass(); Boolean s = dt.PassKey(textBox_key.Text); if (s == true) { if (textBox_rKey.Text.Length == 8) { LogicClass lc = new LogicClass(); Boolean stat = lc.EncryptingMethod(textBox_fLocation.Text, textBox_rKey.Text); if (stat) { MessageBox.Show("Encryption Succesful!", "Encryption", MessageBoxButtons.OK); dt.InsertFileLockList(textBox_fLocation.Text); dt.InsertFileLockPassword(textBox_fLocation.Text, textBox_rKey.Text); MessageBox.Show("Data Inserted into Password Bank", "Done!", MessageBoxButtons.OK); textBox_fLocation.Clear(); } else { MessageBox.Show("Encryption Error....", "Error!", MessageBoxButtons.OK); } } else { if (textBox_rKey.Text.Length < 8) { MessageBox.Show("Password is too short. Password must be a 8-character key.", "Invalid Input!", MessageBoxButtons.OK); } else { MessageBox.Show("Password is too large. Password must be a 8-character key.", "Invalid Input!", MessageBoxButtons.OK); } } } else { MessageBox.Show("Locker password is wrong! Please enter the correct one.", "Wrong Password", MessageBoxButtons.OK); } } catch (Exception Ex) { MessageBox.Show(Ex.Message, "Error!!", MessageBoxButtons.OK); } textBox_key.Clear(); textBox_rKey.Clear(); }
private static void CreateAnotherUserWithContent(LogicClass logic) { Console.WriteLine("/////////////////////////////////////////"); Console.WriteLine("Create another user with one content!"); logic.UserManagement.Registration("Jane Roe", "alma36"); User user = logic.UserManagement.Users.ToList().Find(x => x.Name == "Jane Roe"); logic.ContentManagement.CreateContent("Title", "I love to use this application!!", (int)user.Id); }
public ActionResult Edit(int id) { var output = LibraryItemProcessor.EditLibraryItem(id); var newOutput = mapping.MappForEditToVM(output); newOutput.Category = LogicClass.GetCategoryById(output.CategoryId); List <SelectListItem> listItemsCategory = new List <SelectListItem>(); foreach (var item in newOutput.CategoryList) { if (item.CategoryName == newOutput.Category.CategoryName) { listItemsCategory.Add(new SelectListItem { Text = item.CategoryName, Value = item.CategoryName, Selected = true }); } else { listItemsCategory.Add(new SelectListItem { Text = item.CategoryName, Value = item.CategoryName }); } } List <SelectListItem> listItemsTypes = new List <SelectListItem>(); foreach (var item in newOutput.TypeList) { if (item == newOutput.Type) { listItemsTypes.Add(new SelectListItem { Text = item, Value = item, Selected = true }); } else { listItemsTypes.Add(new SelectListItem { Text = item, Value = item }); } } ViewData["listItemsCategory"] = listItemsCategory; ViewData["listItemsTypes"] = listItemsTypes; return(View(newOutput)); }
private static void SendGift(LogicClass logic) { Console.WriteLine("/////////////////////////////////////////"); Console.WriteLine("Jane Roe send gift to John Doe's content!"); logic.AnalyticsManagement.SendGift(0, 1, 0, 250); Analytic analyticsForJohn = logic.AnalyticsManagement.GetAnalyticsForUser(0).ToList().First(); Console.WriteLine("Owner: {0}\nBuyer: {1}\nContent title: {2}\nCredit: {3}\nTimestamp: {4}", analyticsForJohn.Owner.username, analyticsForJohn.Buyer.username, analyticsForJohn.Content.name, analyticsForJohn.Credit, analyticsForJohn.Timestamp); }
private void A(LogicClass bja, bool bjB) { /* * this.Bja = bja; * this.BjB = bjB; * this.Bjv.Start(); * //*/ this.currentLogicClass = bja; this.currentLogicClassState = bjB; this.timerLogicEditor.Enabled = true; }
public void Init(LogicMethod method) { this.abP = null; this.abp = null; this.abo = method.ParentClass.ClassName; string[] array = new string[method.Parameters.Count]; for (int i = 0; i < method.Parameters.Count; i++) { array[i] = method.Parameters[i].ParameterType.Name; } base.InitMethodNameAndParameterTypes(method.MethodName, array); }
/// <summary> /// Handle all the method calls /// </summary> public static void HandeCalls() { using (LogicClass logic = new LogicClass()) { RegistrateNewUser(logic); CreateContent(logic); CreateAnotherUserWithContent(logic); ListAllUsersAndContents(logic); SendGift(logic); } Console.ReadKey(); }
public ActionResult AddEmployee(string currentCEO) { ViewBag.Message = "Add a Employee"; if (currentCEO != null) { ViewData["ErrorMessage"] = currentCEO; } var model = new EmployeeVM(); model.ManagerList = mapping.MappEmployeeToVM(EmployeeProcessor.GetManagers()); model = LogicClass.setDisplayName(model); return(View(model)); }
/// <summary> /// Structure s /// </summary> private static void SendGift(LogicClass logic) { Console.WriteLine("/////////////////////////////////////////"); Console.WriteLine("Send some gift to the second user!"); Console.WriteLine("Quantity of sending credits (must be smaller than yours, 500):"); int credit = int.Parse(Console.ReadLine()); logic.AnalyticsManagement.SendGift(1, 0, 1, credit); Analytic analytic = logic.AnalyticsManagement.GetAnalyticsForUser(1).ToList().First(); Console.WriteLine("Data of the analytic:"); Console.WriteLine("Owner: {0}\nBuyer: {1}\nContent title: {2}\nCredit: {3}\nTimestamp: {4}", analytic.Owner.username, analytic.Buyer.username, analytic.Content.name, analytic.Credit, analytic.Timestamp); }
private static void CreateContent(LogicClass logic) { Console.WriteLine("/////////////////////////////////////////"); Console.WriteLine("Create a new content for John Doe!"); User user = logic.UserManagement.Users.ToList().Find(x => x.Name == "John Doe"); logic.ContentManagement.CreateContent("FirstTitle", "Very nice content text!!!", (int)user.Id); List <Content> contents = logic.ContentManagement.Contents.ToList(); Content content = contents.First(); Console.WriteLine("{0} - {1}\n{2}\n", content.User.username, content.Name, content.File); Console.ReadKey(); }
public RegisterModel( UserManager <CustomUser> userManager, SignInManager <CustomUser> signInManager, ILogger <RegisterModel> logger, IEmailSender emailSender, RoleManager <IdentityRole> roleManager, LogicClass logicClass) { _userManager = userManager; _signInManager = signInManager; _logger = logger; _emailSender = emailSender; _roleManager = roleManager; _logicClass = logicClass; }
public ActionResult Edit(int id, string currentCEO) { var tempModel = mapping.MappEmployeeToVM(EmployeeProcessor.EditEmployee(id)); var output = tempModel[0]; output.ManagerList = mapping.MappEmployeeToVM(EmployeeProcessor.GetManagers()); output = LogicClass.setDisplayName(output); if (currentCEO != null) { ViewData["ErrorMessage"] = currentCEO; } return(View(output)); }
public ActionResult Edit(LibraryItemVM model) { if (ModelState.IsValid) { model = LogicClass.SerCategoryFromVM(model); model = LogicClass.SetBorrowDate(model); var outModel = mapping.MappToLibraryItemModelFromVM(model); LibraryItemProcessor.SaveLibraryItem(outModel); } return(RedirectToAction("Index")); }
public void TestMethod1() { bool actualBool = true; actualBool.Should().BeTrue(); int actualInt = 234; actualInt.Should().BeInRange(0, 255); actualInt.Should().BePositive(); actualInt.Should().Be(234); double actualDouble = 234.567; actualDouble.Should().BeApproximately(234.5, 0.25); actualDouble.Should().BeInRange(0, 255); List <string> actualList = new List <string>() { "ala", "ma", "kota" }; actualList.Should().NotBeEmpty(); actualList.Should().NotContainNulls(); actualList.Should().OnlyHaveUniqueItems(); actualList.Should().HaveElementPreceding("kota", "ma"); ChopData actualComplex = new ChopData(); actualComplex.Words = new string[] { "ala", "ma", "kota" }; actualComplex.WordsCount = 3; ChopData expectedComplex = new ChopData(); expectedComplex.Words = new string[] { "ala", "ma", "kota" }; expectedComplex.WordsCount = 3; actualComplex.Should().BeEquivalentTo(expectedComplex); string actualString = "alaMaKOta"; actualString.Should().NotBeNullOrEmpty(); LogicClass testedClass = new LogicClass(); Action act = () => testedClass.ThrowException(); act.Should().Throw <Exception>().WithMessage("Invalida argument exception"); }
public ActionResult Create(LibraryItemVM model) { if (model.CategoryName != "" || model.CategoryName != null) { model = LogicClass.CleanCategory(model); } if (ModelState.IsValid) { model = LogicClass.SetIsBorrowable(model); LibraryItemProcessor.CreateLibraryItem(mapping.MappToLibraryItemModelFromVM(model)); return(RedirectToAction("Index")); } return(RedirectToAction("Create")); }
private static void RegistrateNewUser(LogicClass logic) { Console.WriteLine("/////////////////////////////////////////"); Console.WriteLine("Registrate a new user!"); logic.UserManagement.Registration("John Doe", "alma25"); Console.WriteLine("John Doe is registered: {0}", logic.UserManagement.IsRegistrated("John Doe", "alma25")); Console.WriteLine("Give him some credit"); logic.UserManagement.AddCredit(0, 500); List <User> users = logic.UserManagement.Users.ToList(); User user = users.Find(x => x.Name == "John Doe"); Console.WriteLine("User details : ID: {0} Name: {1} Credit: {2}", user.Id, user.Name, user.Credit); Console.WriteLine(); Console.ReadKey(); }
public ActionResult AddEmployee(EmployeeVM model) { if (ModelState.IsValid) { if (model.IsCEO) { var currentCeo2 = EmployeeProcessor.CheckForCEO(); if (currentCeo2 != null) { var currentCeo = LogicClass.GetCEOErrorMessage(currentCeo2); return(RedirectToAction("AddEmployee", new { currentCEO = currentCeo })); } model.ManagerId = null; } if (!model.IsCEO) { model.ManagerId = LogicClass.CheckManager(model); } if (!model.IsCEO && model.ManagerId < 0) { string message = "Every employee need to have a manager, please select Manager"; return(RedirectToAction("AddEmployee", new { currentCEO = message })); } else if (!model.IsCEO && model.ManagerId == 0) { string message = "Only a manager can have the CEO as their manager"; return(RedirectToAction("AddEmployee", new { currentCEO = message })); } model.Salary = LogicClass.CalculateSalary(model); var outModel = mapping.MappToEmployeeModelFromVM(model); EmployeeProcessor.CreateEmployee(outModel); return(RedirectToAction("Index")); } return(RedirectToAction("AddEmployee")); }
/// <summary> /// Structure s /// </summary> private static void ListAllUsersAndContents(LogicClass logic) { Console.WriteLine("/////////////////////////////////////////"); Console.WriteLine("List all users and contents!"); List <User> users = logic.UserManagement.Users.ToList(); List <Content> contents = logic.ContentManagement.Contents.ToList(); Console.WriteLine("/////////USERS//////////"); foreach (User user in users) { Console.WriteLine("{0} - {1}\n", user.Id, user.Name); } Console.WriteLine("/////////CONTENS//////////"); foreach (Content content in contents) { Console.WriteLine("{0} - {1}\n{2}\n", content.User.username, content.Name, content.File); } }
// To decrypt the file private void btn_unlock_click(object sender, EventArgs e) { try { DataAccessClass dac = new DataAccessClass(); Boolean s = dac.PassKey(textBox_key.Text); if (s == true) { LogicClass lc1 = new LogicClass(); Boolean stat = lc1.DecryptingMethod(textBox_fLocation.Text, textBox_rKey.Text); if (stat) { MessageBox.Show("Decryption Succesful!", "Decryption", MessageBoxButtons.OK); dac.DeleteFileLockList(textBox_fLocation.Text); dac.DeleteFileLockPassword(textBox_fLocation.Text); MessageBox.Show("Data Inserted into Password Bank.", "DONE", MessageBoxButtons.OK); textBox_fLocation.Clear(); } else { MessageBox.Show("Decryption Error!", "Error", MessageBoxButtons.OK); } } else { MessageBox.Show("Wrong Password!", "Error", MessageBoxButtons.OK); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK); } textBox_key.Clear(); textBox_rKey.Clear(); }
private static void CreateContent(LogicClass logic) { Console.WriteLine("/////////////////////////////////////////"); Console.WriteLine("Create a new content for your user!"); Console.WriteLine("Type the title of the content:"); string title = Console.ReadLine(); Console.WriteLine("Type the text of the content:"); string text = Console.ReadLine(); User user = logic.UserManagement.Users.ToList().First(); logic.ContentManagement.CreateContent(title, text, (int)user.Id); List <Content> contents = logic.ContentManagement.Contents.ToList(); Content content = contents.First(); Console.WriteLine("Your new content:"); Console.WriteLine("{0} - {1}\n{2}\n", content.User.username, content.Name, content.File); Console.ReadKey(); }
public Adapter() { _logic = new LogicClass( LogicConstants.LOG_FILE_NAME, LogicConstants.LOG_FILE_FULL_PATH, LogicConstants.LOG_LEVEL); #region Connected Logic Events _logic.DBConnected += OnDBConnected; _logic.DBDisconnected += OnDBDisconnected; #endregion #region Connected Home View Events _controller.ReloadHomeView += OnReloadHomeView; #endregion #region Connected Settings View Events _controller.ReloadSettingsView += OnReloadSettingsView; _controller.OpenConfig += OnOpenConfig; _controller.ActivateConfig += OnActivateConfig; _controller.SaveNewUserName += OnSaveNewUserName; _controller.SaveNewPassword += OnSaveNewPassword; #endregion #region Connected Data View Events _controller.RequestLogData += OnRequestLogData; _controller.RequestLogLevelFilteredData += OnRequestLogLevelFilteredData; _controller.SaveData += OnSaveData; #endregion #region Connected Login Window Events _controller.GetLoginData += OnGetLoginData; #endregion LoadHomeView(); LoadSettingsView(); LoadDataView(); LoadAboutView(); LogHandler.WriteLog(this + " Created", LogLevel.DEBUG); }