Skip to content
This repository has been archived by the owner on Apr 28, 2023. It is now read-only.

Commit

Permalink
Fixed xml file getting reset if 2 assignments had the same name
Browse files Browse the repository at this point in the history
  • Loading branch information
LambdaGaming committed Mar 6, 2021
1 parent 78ca6b0 commit e77ad5d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
14 changes: 14 additions & 0 deletions AssignmentReminder/AssignmentManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;

namespace AssignmentReminder
{
Expand Down Expand Up @@ -33,6 +35,18 @@ private void AddButton_Click( object sender, EventArgs e )
settings.Save( settingsdir );
}

XDocument checkname = XDocument.Load( settingsdir );
var names = from c in checkname.Root.Descendants( "assignment" ) select c.Element( "name" ).Value;

foreach ( string name in names )
{
if ( NameBox.Text == name )
{
MessageBox.Show( "An assignment with this name already exists. Please choose a different name.", "Name Already Taken", MessageBoxButtons.OK, MessageBoxIcon.Error );
return;
}
}

settings.Load( settingsdir );
XmlElement newitem = settings.CreateElement( "assignment" );

Expand Down
4 changes: 2 additions & 2 deletions AssignmentReminder/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion( "1.4.1" )]
[assembly: AssemblyFileVersion( "1.4.1" )]
[assembly: AssemblyVersion( "1.4.2" )]
[assembly: AssemblyFileVersion( "1.4.2" )]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
- To delete a completed assignment, double click the entry for it in the assignment viewer.
- If you want to delete all assignments at once, navigate to %AppData%/AssignmentReminder and delete the settings.xml file.

# Issues & Pull Requests
## Issues & Pull Requests
If you would like to contribute to this repository by creating an issue or pull request, please refer to the [contributing guidelines.](https://lambdagaming.github.io/contributing.html)

0 comments on commit e77ad5d

Please sign in to comment.