Skip to content

Commit

Permalink
Delete irrelevant content
Browse files Browse the repository at this point in the history
  • Loading branch information
BloodShop committed Aug 16, 2022
1 parent 2a45483 commit 9ca4a21
Show file tree
Hide file tree
Showing 18 changed files with 45 additions and 41 deletions.
1 change: 1 addition & 0 deletions Dal/Dal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
<Compile Include="Comparers\CompareLastName.cs" />
<Compile Include="Comparers\CompareName.cs" />
<Compile Include="DataMock.cs" />
<Compile Include="IRepository.cs" />
<Compile Include="StudentContainer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Dal.rd.xml" />
Expand Down
7 changes: 3 additions & 4 deletions Dal/DataMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ namespace Dal
public class DataMock
{
static Dictionary<int, Student> _students;
static DataMock _instance;
static readonly object _lock = new object();

private static readonly object _lock = new object();
public static List<IComparer<Student>> SortStudent { get; private set; }
public static int UniqueSeed { get; private set; } = 1000;
public Dictionary<int, Student> Students { get => _students; }


public static int UniqueSeed = 100;
static DataMock _instance;
public static DataMock Instance
{
get
Expand Down
12 changes: 12 additions & 0 deletions Dal/IRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Linq;

namespace Dal
{
interface IRepository<T>
{
void Add(T item);
void Remove(T item);
T Update(T item1, T item2);
IQueryable<T> GetAll();
}
}
8 changes: 4 additions & 4 deletions Dal/StudentContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Dal
{
public class StudentContainer : IEnumerable
public class StudentContainer : IEnumerable, IRepository<Student>
{
readonly DataMock _data = DataMock.Instance;
int uniqueSeed = DataMock.UniqueSeed;
Expand Down Expand Up @@ -37,9 +37,10 @@ public string this[string email]
return phoneNum;
}
}

public List<Student> Sort(IComparer<Student> comparison)
{
List<Student> temp = GetStudents().ToList();
List<Student> temp = GetAll().ToList();
temp.Sort(comparison);
return temp;
}
Expand All @@ -65,8 +66,7 @@ public Student Update(Student old, Student @new)
}
return @new;
}
public IQueryable<Student> GetStudents() => _data.Students.Values.AsQueryable();

public IQueryable<Student> GetAll() => _data.Students.Values.AsQueryable();

public IEnumerator GetEnumerator()
{
Expand Down
2 changes: 1 addition & 1 deletion Model/Student.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private set
{
if (IsValidPhone(value))
_homePhoneNum = value;
else _homePhoneNum = "09999999";
else _homePhoneNum = "0999999999";
}
}

Expand Down
Binary file added StudentsContainer/Assets/BadgeLogo.scale-400.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified StudentsContainer/Assets/Square150x150Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified StudentsContainer/Assets/Square44x44Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed StudentsContainer/Assets/StoreLogo.png
Binary file not shown.
Binary file added StudentsContainer/Assets/StoreLogo.scale-400.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 2 additions & 9 deletions StudentsContainer/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
mc:Ignorable="d"
xmlns:x1="using:Model"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Page.DataContext>
<local:MainViewModel/>
</Page.DataContext>
Expand Down Expand Up @@ -36,7 +35,6 @@
FontSize="50" FontFamily="Algerian" Text="Search" TextWrapping="WrapWholeWords"/>
<TextBox x:Name="SearchEmailTB" Text="{Binding SearchEmail, Mode=TwoWay}" Margin="0,15,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center"
MinWidth="150" PlaceholderText="Enter Email"/>

<Button x:Name="SearchBtn" Margin="0,15,0,0" HorizontalAlignment="Center" VerticalAlignment="Center"
MinWidth="150" Content="Search" Command="{Binding SearchCommand}" IsEnabled="{Binding IsSearchSpecificValid, Mode=TwoWay}"/>
<Button x:Name="ClearBtn" Margin="0,15,0,0" HorizontalAlignment="Center" VerticalAlignment="Center"
Expand All @@ -57,14 +55,10 @@
MinWidth="150" PlaceholderText="Enter Email"/>
<TextBox x:Name="EditGradeTB" Text="{Binding EditGrade, Mode=TwoWay}" Margin="0,15,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center"
MinWidth="150" PlaceholderText="Enter Grade"/>

<Button x:Name="EditBtn" Margin="0,15,0,0" HorizontalAlignment="Center" VerticalAlignment="Center"
MinWidth="150" Content="Edit Student" Command="{Binding EditCommand}" IsEnabled="{Binding IsEditValid, Mode=TwoWay}"/>

</StackPanel>



<StackPanel Grid.Row="1" Grid.Column="3" Grid.RowSpan="3">
<TextBlock Grid.Row="0" Grid.Column="1"
HorizontalAlignment="Stretch" VerticalAlignment="Center" TextAlignment="Center"
Expand Down Expand Up @@ -113,12 +107,11 @@
<TextBlock Margin="5,0,0,0" Text="{Binding PersonalPhoneNum}" FontFamily="Bahnschrift" FontStyle="Italic"/>
<TextBlock Margin="15,0,0,0" Text="Home:" FontFamily="Bahnschrift"/>
<TextBlock Margin="5,0,0,0" Text="{Binding HomePhoneNum}" FontFamily="Bahnschrift" FontStyle="Italic"/>
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>

</Grid>
</Page>
</Page>
3 changes: 2 additions & 1 deletion StudentsContainer/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
Square44x44Logo="Assets\Square44x44Logo.png"
Description="StudentsContainer"
BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" Square71x71Logo="Assets\Square71x71Logo.png"/>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
<uap:LockScreen Notification="badge" BadgeLogo="Assets\BadgeLogo.png"/>
</uap:VisualElements>
</Application>
</Applications>
Expand Down
6 changes: 5 additions & 1 deletion StudentsContainer/StudentsContainer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,17 @@
</AppxManifest>
</ItemGroup>
<ItemGroup>
<Content Include="Assets\BadgeLogo.scale-400.png" />
<Content Include="Assets\Square44x44Logo.scale-400.png" />
<Content Include="Assets\Square44x44Logo.targetsize-256_altform-unplated.png" />
<Content Include="Assets\Square71x71Logo.scale-400.png" />
<Content Include="Assets\StoreLogo.scale-400.png" />
<Content Include="Properties\Default.rd.xml" />
<Content Include="Assets\LockScreenLogo.scale-200.png" />
<Content Include="Assets\SplashScreen.scale-200.png" />
<Content Include="Assets\Square150x150Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Assets\StoreLogo.png" />
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
</ItemGroup>
<ItemGroup>
Expand Down
36 changes: 15 additions & 21 deletions StudentsContainer/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Windows.UI.Popups;
Expand Down Expand Up @@ -71,17 +68,7 @@ public Student SelectedStudent
}
}

#region Props
bool _isSearchValid;
public bool IsSearchValid
{
get => _isSearchValid;
private set
{
_isSearchValid = value;
RaisePropertyChanged(nameof(IsSearchValid));
}
}
#region Props MVVM
bool _isRemoveValid;
public bool IsRemoveValid
{
Expand All @@ -92,8 +79,17 @@ private set
RaisePropertyChanged(nameof(IsRemoveValid));
}
}

#region SearchEngine Properties
bool _isSearchValid;
public bool IsSearchValid
{
get => _isSearchValid;
private set
{
_isSearchValid = value;
RaisePropertyChanged(nameof(IsSearchValid));
}
}
bool _isSearchSpecificValid;
public bool IsSearchSpecificValid
{
Expand Down Expand Up @@ -289,7 +285,7 @@ public int EditGrade
#endregion
#endregion

public MainViewModel() => ResultStudents = _studentContainer.GetStudents();
public MainViewModel() => ResultStudents = _studentContainer.GetAll();

public ICommand SortCommand => new DelegateCommand(SortStudents);
public ICommand RemoveCommand => new DelegateCommand(RemoveStudent);
Expand All @@ -301,7 +297,7 @@ public int EditGrade
private void EditStudent()
{
SelectedStudent.Update(_editEmail, _editPhone, _editGrade);
ResultStudents = _studentContainer.GetStudents();
ResultStudents = _studentContainer.GetAll();
}
async void SearchStudent()
{
Expand All @@ -314,16 +310,14 @@ async void SearchStudent()
void AddStudent()
{
_studentContainer.Add(new Student(FirstName, LastName, Email, FinalGrade, PersonalPhoneNum, HomePhoneNum));
ResultStudents = _studentContainer.GetStudents();
ResultStudents = _studentContainer.GetAll();
}
void RemoveStudent()
{
_studentContainer.Remove(SelectedStudent);
ResultStudents = _studentContainer.GetStudents();
ResultStudents = _studentContainer.GetAll();
}
void SortStudents() => ResultStudents = _studentContainer.Sort(SelectedComparer);


bool IsValidEmail(string email)
{
try
Expand Down

0 comments on commit 9ca4a21

Please sign in to comment.