Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
filipvidakovic committed Jul 4, 2024
2 parents 5dc00e1 + d761cdb commit 4b7cd44
Show file tree
Hide file tree
Showing 16 changed files with 277 additions and 75 deletions.
4 changes: 2 additions & 2 deletions AdoptionAgency/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace AdoptionAgency
public partial class App : Application
{
private readonly IHost _host;
public static Person? LoggedPerson;
public static Person? LoggedIn;

public App()
{
Expand Down Expand Up @@ -59,7 +59,7 @@ private void ApplyMigrations()
using (var scope = _host.Services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
//db.Database.Migrate();
db.Database.Migrate();
}
}

Expand Down
1 change: 1 addition & 0 deletions AdoptionAgency/Backend/Repositories/DatabaseContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ private void ConfigurePersonEntity(ModelBuilder modelBuilder)
user.Property(u => u.Username).HasColumnName("Username");
user.Property(u => u.Password).HasColumnName("Password");
user.Property(u => u.Type).HasColumnName("Type");
user.Property(u => u.Status).HasColumnName("Status");
});
}
}
Expand Down
6 changes: 3 additions & 3 deletions AdoptionAgency/Frontend/View/Authentication/Login.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using AdoptionAgency.Backend.Services.AuthentificationService;
using AdoptionAgency.Frontend.ViewModel;
using AdoptionAgency.Frontend.ViewModel.Authentication;
using System.Windows;

Expand All @@ -20,13 +19,14 @@ public Login(MainWindow mainWindow)
private void LoginBtn_Click(object sender, RoutedEventArgs e)
{
var loginService = new LoginService();
App.LoggedPerson = loginService
.GetByCredentials(ViewModel.UserName, ViewModel.Password);
App.LoggedIn = loginService.GetByCredentials(ViewModel.UserName, ViewModel.Password);

if (ViewModel.Login())
{
Close();
MainWindow.Close();
}

}
}
}
2 changes: 1 addition & 1 deletion AdoptionAgency/Frontend/View/UserViews/MemberView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<Button x:Name="addPostBtn" Content="Add new post" Height="33" Width="100" BorderBrush="White" Background="#FFAFBDAD" Foreground="#FF577B47" FontFamily="Elephant"
Margin="10,0" Click="AddPostBtn_Click"/>
<Button x:Name="logoutBtn" Content="Logout" Height="33" Width="100" BorderBrush="White" Background="#FFAFBDAD" Foreground="#FF577B47" FontFamily="Elephant"
Margin="10,0" Click="logoutBtn_Click"/>
Margin="10,0" Click="LogoutBtn_Click"/>
</StackPanel>
</Grid>

Expand Down
5 changes: 3 additions & 2 deletions AdoptionAgency/Frontend/View/UserViews/MemberView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private void AskUserForPermanentAdoption(PostViewModel post)
{
AdoptionRequest request = new()
{
Adopter = post.Person, // TODO: when loggedIn is saved
Adopter = App.LoggedIn,
Animal = post.Animal,
SentAt = DateTime.Now,
ReceivedAt = DateTime.Now,
Expand All @@ -63,8 +63,9 @@ private void AddPostBtn_Click(object sender, RoutedEventArgs e)
window.Show();
}

private void logoutBtn_Click(object sender, RoutedEventArgs e)
private void LogoutBtn_Click(object sender, RoutedEventArgs e)
{
App.LoggedIn = null;
Close();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<Window x:Class="AdoptionAgency.Frontend.View.VolunteerView.VolunteerRequestsView"
<Window x:Class="AdoptionAgency.Frontend.View.UserViews.VolunteerRequestsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:AdoptionAgency.Frontend.View.VolunteerView"
mc:Ignorable="d"
Title="VolunteerRequestsView" Height="450" Width="800">
Title="VolunteerRequestsView"
Height="800"
Width="800"
WindowStartupLocation="CenterScreen"
ResizeMode="NoResize">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
Expand All @@ -18,7 +21,7 @@
<RowDefinition Height="2.5*"/>
<RowDefinition Height=".5*"/>
</Grid.RowDefinitions>
<ListView Grid.Row="1" Grid.Column="1" Margin="0,20" ItemsSource="{Binding MembersView}" HorizontalAlignment="Center" SelectedItem="{Binding SelectedMember}">
<ListView Grid.Column="1" Margin="0,10,0,29" ItemsSource="{Binding MembersView}" HorizontalAlignment="Left" SelectedItem="{Binding SelectedMember}" Width="620" Grid.Row="1">
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding Username}" Header="Username"/>
Expand All @@ -30,12 +33,12 @@
</ListView.View>
</ListView>
<StackPanel VerticalAlignment="Center" Grid.Row="2" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Center">
<Button Click="AcceptReqBtn" Margin="20,0" MaxHeight="96" MaxWidth="96">
Accept request
</Button>
<Button Click="RejectReqBtn" Margin="20,0" MaxHeight="96" MaxWidth="96">
Reject request
</Button>

<Button x:Name="AcceptReqBtn" Content="Accept request" BorderBrush="White" Background="#FFAFBDAD" Foreground="#FF577B47" FontFamily="Elephant"
Margin="10,0" Height="33" Width="150" Click="AcceptReqBtn_Click"/>
<Button x:Name="RejectReqBtn" Content="Reject request" BorderBrush="White" Background="#FFAFBDAD" Foreground="#FF577B47" FontFamily="Elephant"
Margin="10,0" Height="33" Width="150" Click="RejectReqBtn_Click"/>

</StackPanel>
</Grid>
</Window>
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
using AdoptionAgency.Backend.Services;
using AdoptionAgency.Backend.Domain.Model.Common;
using AdoptionAgency.Backend.Services;
using AdoptionAgency.Frontend.ViewModel.VolunteerViewModel;
using AdoptionAgency.Backend.Domain.Model;
using System.Windows;
using AdoptionAgency.Backend.Domain.Model.Person.Member;
using AdoptionAgency.Backend.Domain.Model.Person;
using AdoptionAgency.Backend.Domain.Model.Common;

namespace AdoptionAgency.Frontend.View.VolunteerView
namespace AdoptionAgency.Frontend.View.UserViews
{
/// <summary>
/// Interaction logic for VolunteerRequestsView.xaml
/// </summary>
public partial class VolunteerRequestsView : Window
{
public VolunteerRequestsViewModel ViewModel { get; set; }
Expand All @@ -20,7 +14,7 @@ public VolunteerRequestsView()
ViewModel = new VolunteerRequestsViewModel();
DataContext = ViewModel;
}
private void AcceptReqBtn(object sender, RoutedEventArgs e)
private void AcceptReqBtn_Click(object sender, RoutedEventArgs e)
{
var member = ViewModel.SelectedMember;
member.User.Status = Status.Accepted;
Expand All @@ -29,7 +23,7 @@ private void AcceptReqBtn(object sender, RoutedEventArgs e)
var members = ViewModel.Members;
members.Remove(member);
}
private void RejectReqBtn(object sender, RoutedEventArgs e)
private void RejectReqBtn_Click(object sender, RoutedEventArgs e)
{
var member = ViewModel.SelectedMember;
member.User.Status = Status.Rejected;
Expand Down
134 changes: 134 additions & 0 deletions AdoptionAgency/Frontend/View/UserViews/VolunteerView.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<Window x:Class="AdoptionAgency.Frontend.View.UserViews.VolunteerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="AdoptionAgency"
Height="800"
Width="800"
WindowStartupLocation="CenterScreen"
ResizeMode="NoResize">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border Grid.Row="2" Height="1" Background="#FF577B47" HorizontalAlignment="Stretch" VerticalAlignment="Top"/>

<Grid Grid.Row="0" Background="#FFE0E0E0" Margin="0,0,0,613" Grid.RowSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>

<Image Source="/Frontend/Assets/Logos/logo.png" Width="59" Height="53" Margin="66,13,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>

<TextBlock Text="Animal Adoption Agency" Foreground="#FF577B47" FontSize="19" FontFamily="Elephant" TextWrapping="Wrap" Margin="119,34,0,-11" HorizontalAlignment="Left" FontStyle="Italic" Width="279"/>

<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,20">
<Button x:Name="logoutBtn" Content="Logout" Height="33" Width="100" BorderBrush="White" Background="#FFAFBDAD" Foreground="#FF577B47" FontFamily="Elephant"
Margin="10,0" Click="LogoutBtn_Click"/>
</StackPanel>
</Grid>

<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,100,0,0">
<Button x:Name="addPostBtn" Content="Add new post" BorderBrush="White" Background="#FFAFBDAD" Foreground="#FF577B47" FontFamily="Elephant"
Margin="10,0" Height="33" Width="150" Click="AddPostBtn_Click"/>
<Button x:Name="viewPostReqBtn" Content="View post requests" BorderBrush="White" Background="#FFAFBDAD" Foreground="#FF577B47" FontFamily="Elephant"
Margin="10,0" Height="33" Width="150"/>
<Button x:Name="viewRegReqBtn" Content="View registration requests" BorderBrush="White" Background="#FFAFBDAD" Foreground="#FF577B47" FontFamily="Elephant"
Margin="10,0" Height="33" Width="164" Click="ViewRegReqBtn_Click"/>
</StackPanel>

<ScrollViewer Grid.Row="1" Background="#FFE5E5E5" Margin="0,10,0,0">
<ListBox x:Name="postsListBox" ItemsSource="{Binding Posts}" HorizontalAlignment="Center" Background="#FFF3FFF1">
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#FF577B47" BorderThickness="1" Margin="5" Padding="10">
<StackPanel>
<TextBlock Text="{Binding Author}" FontSize="20" Foreground="#FF577B47" TextWrapping="Wrap" FontWeight="Bold" VerticalAlignment="Center"/>
<TextBlock Text="{Binding Description}" FontSize="15" Foreground="#FF577B47" TextWrapping="Wrap" FontWeight="Bold" VerticalAlignment="Center"/>
<Image Source="{Binding IconPath}" Width="120" Height="120" HorizontalAlignment="Right" VerticalAlignment="Top"/>

<Separator BorderBrush="#FF577B47" BorderThickness="1"/>

<StackPanel Margin="15,0,0,0">
<TextBlock FontSize="15" Foreground="#FF577B47">
<TextBlock.Text>
<MultiBinding StringFormat="Species: {0}">
<Binding Path="Animal.Species" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<TextBlock FontSize="15" Foreground="#FF577B47">
<TextBlock.Text>
<MultiBinding StringFormat="Estimated year of birth: {0:yyyy}">
<Binding Path="Animal.BirthDate" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<TextBlock FontSize="15" Foreground="#FF577B47">
<TextBlock.Text>
<MultiBinding StringFormat="Found Location: {0}">
<Binding Path="Animal.FoundLocation" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>

<TextBlock FontSize="15" Foreground="#FF577B47">
<TextBlock.Text>
<MultiBinding StringFormat="Health Condition: {0}">
<Binding Path="Animal.HealthCondition" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>

<TextBlock FontSize="15" Foreground="#FF577B47">
<TextBlock.Text>
<MultiBinding StringFormat="Behaviour: {0}">
<Binding Path="Animal.Behaviour" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>

<TextBlock FontSize="15" Foreground="#FF577B47">
<TextBlock.Text>
<MultiBinding StringFormat="Gender: {0}">
<Binding Path="Animal.Gender" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>

<TextBlock FontSize="15" Foreground="#FF577B47">
<TextBlock.Text>
<MultiBinding StringFormat="Weight: {0}">
<Binding Path="Animal.Weight" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>

<TextBlock FontSize="15" Foreground="#FF577B47">
<TextBlock.Text>
<MultiBinding StringFormat="Size: {0}">
<Binding Path="Animal.Size" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</StackPanel>

<ContentControl Content="{Binding ImageDisplays}" Margin="0,10,0,0" Width="450" Height="300"/>
<Button x:Name="adoptBtn" Content="Adopt" Height="33" Width="100" BorderBrush="White" Background="#FFAFBDAD" Foreground="#FF577B47" FontFamily="Elephant"
HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="10,10,0,0" Click="AdoptBtn_Click"/>
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>

<Border Grid.Row="2" Height="1" Background="#FF577B47" HorizontalAlignment="Stretch" VerticalAlignment="Top"/>
</Grid>
</Window>
78 changes: 78 additions & 0 deletions AdoptionAgency/Frontend/View/UserViews/VolunteerView.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using AdoptionAgency.Backend.Domain.Model.Animal;
using AdoptionAgency.Backend.Domain.Model.Common;
using AdoptionAgency.Backend.Services.AnimalServices;
using AdoptionAgency.Frontend.ViewModel.PostViewModels.EntityViewModels;
using AdoptionAgency.Frontend.ViewModel.VolunteerViewModel;
using System.Windows;
using System.Windows.Controls;

namespace AdoptionAgency.Frontend.View.UserViews
{
public partial class VolunteerView : Window
{
public VolunteerPageViewModel ViewModel { get; set; }
public VolunteerView()
{
InitializeComponent();
ViewModel = new VolunteerPageViewModel();
DataContext = ViewModel;
}

private void AdoptBtn_Click(object sender, RoutedEventArgs e)
{
Button adoptButton = sender as Button;

Check warning on line 23 in AdoptionAgency/Frontend/View/UserViews/VolunteerView.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.
var post = adoptButton.DataContext as PostViewModel;

Check warning on line 24 in AdoptionAgency/Frontend/View/UserViews/VolunteerView.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

var requestService = new AdoptionRequestService();

if (post == null) return;
postsListBox.SelectedItem = post;

if (post.Animal.Adopted)
ShowInfo("Animal is already adopted, please select another.");

else if (requestService.Exists(post.Animal, post.Person))
ShowInfo("Adoption request has already been sent.");

else
AskUserForPermanentAdoption(post);
}

private void AskUserForPermanentAdoption(PostViewModel post)
{
AdoptionRequest request = new()
{
Adopter = post.Person, // TODO: when loggedIn is saved
Animal = post.Animal,
SentAt = DateTime.Now,
ReceivedAt = DateTime.Now,
Status = Status.Pending,
FosterUntil = DateTime.Now
};
AdoptionConfirmation confirmation = new(request);
confirmation.Show();
}

private void ShowInfo(string text)
{
MessageBox.Show(text, "Notification", MessageBoxButton.OK, MessageBoxImage.Information);
}

private void AddPostBtn_Click(object sender, RoutedEventArgs e)
{
var window = new Post.Post();
window.Show();
}

private void LogoutBtn_Click(object sender, RoutedEventArgs e)
{
Close();
}

private void ViewRegReqBtn_Click(object sender, RoutedEventArgs e)
{
VolunteerRequestsView window = new();
window.Show();
}
}
}
12 changes: 0 additions & 12 deletions AdoptionAgency/Frontend/View/VolunteerView/VolunteerView.xaml

This file was deleted.

Loading

0 comments on commit 4b7cd44

Please sign in to comment.