public void ChangeAdminDetails(string newPassword, string confirmPassword, string currentPassword) { string title = "Admin Details"; if (newPassword != confirmPassword) { MessageBox.Show("Passwords do not match", title, MessageBoxButton.OK, MessageBoxImage.Error); return; } User obj = AppDbCxt.Users.First(r => 1 == 1); // check if current password matches provided if (!obj.ConfirmPassword(currentPassword)) { MessageBox.Show("Current Password Provided does not match stored password", title, MessageBoxButton.OK, MessageBoxImage.Error); return; } obj.Name = UserName; using (MD5 md5Hash = MD5.Create()) { EncryptionTools enc = new EncryptionTools(md5Hash); obj.Password = enc.GetMd5Hash(newPassword); } AppDbCxt.SaveChanges(); MessageBox.Show("Details Successfully changed", title, MessageBoxButton.OK, MessageBoxImage.Information); CurrentPage = new ViewBooks(this); }
public void Dispatch(string request) { try { string[] tokens = request.Split(' '); int custId = Int32.Parse(tokens[1]); string action = tokens[2]; if (tokens[0] != "GET" || !customerExists(custId) || tokens.Length != 3 || !action.StartsWith(WEBSITE_NAME)) { throw new InvalidRequestException(); } // strip http://www.nezarka.net/ from request action = action.Substring(WEBSITE_NAME.Length, action.Length - WEBSITE_NAME.Length); string[] act_list = action.Split('/'); if (act_list.Length == 1 && act_list[0] == "Books") { // http://www.nezarka.net/Books ViewBooks.Render(custId, modelStore); } else if (act_list.Length == 3 && act_list[0] == "Books" && act_list[1] == "Detail") { // http://www.nezarka.net/Books/Detail/_Book_Id_ ViewBookDetail.Render(custId, Int32.Parse(act_list[2]), modelStore); } else if (act_list.Length == 1 && act_list[0] == "ShoppingCart") { // http://www.nezarka.net/ShoppingCart ViewShoppingCart.Render(custId, modelStore); } else if (act_list.Length == 3 && act_list[0] == "ShoppingCart" && act_list[1] == "Add") { // http://www.nezarka.net/ShoppingCart/Add/_BookId_ CartController.Add(custId, Int32.Parse(act_list[2]), modelStore); } else if (act_list.Length == 3 && act_list[0] == "ShoppingCart" && act_list[1] == "Remove") { // http://www.nezarka.net/ShoppingCart/Remove/_BookId_ CartController.Remove(custId, Int32.Parse(act_list[2]), modelStore); } else { ViewInvalidRequest.Render(); } } catch (Exception ex) { if (ex is InvalidRequestException || ex is FormatException || ex is IndexOutOfRangeException) { ViewInvalidRequest.Render(); } else { throw; } } }
private void Dashboard_Load(object sender, EventArgs e) { ViewBooks viewBooks = new ViewBooks(); ViewAuthors viewAuthors = new ViewAuthors(); ViewGenres viewGenres = new ViewGenres(); ViewPublishers viewPublishers = new ViewPublishers(); ViewStocks viewStocks = new ViewStocks(); Visitors visitors = new Visitors(); Lends lends = new Lends(); viewBooks.MdiParent = this; //MdiChildren[0] viewAuthors.MdiParent = this; //MdiChildren[1] viewGenres.MdiParent = this; //MdiChildren[2] viewPublishers.MdiParent = this; //MdiChildren[3] viewStocks.MdiParent = this; //MdiChildren[4] visitors.MdiParent = this; //MdiChildren[5] lends.MdiParent = this; //MdiChildren[6] }
public void SaveNewBorrow() { using (LibAppContext dbConn = new LibAppContext()) { if (CurrentBook.Available <= 0) { MessageBox.Show("No Books are available to lend out"); CurrentPage = new ViewBooks(this); return; } LendBook.BookId = CurrentBook.Id; dbConn.BorrowedItems.Add(LendBook); dbConn.SaveChanges(); } LoadBorrowed(); LoadBooks(); CurrentPage = new ViewBooks(this); }