Skip to content

Commit

Permalink
chore: update appointments handling, services and general features in…
Browse files Browse the repository at this point in the history
… Groomwise application

- Update appointment services to use new Community Toolkit MVVM, replacing old MVVMGen.

- Enrich Appointment model with: appointment overlapping check, available time-slots generation for new appointments

- Remove dependency on Lombok and use Community Toolkit MVVM.

- Add appointment cancellation and saving functionalities, with necessary validation and notifications.

- Move to DateTime instead of separate Date and Time entities, for easier management of appointments and services.

- Add service removal functionality with adjustments to overall appointment duration

- Rework Toast notifications to self-remove themselves after a cooldown period.

- Various related improvements and clean-ups on all associated files.

Signed-off-by: Russell Camo <[email protected]>
  • Loading branch information
russkyc committed Sep 3, 2023
1 parent a0e4e72 commit cd2c5fe
Show file tree
Hide file tree
Showing 22 changed files with 376 additions and 165 deletions.
8 changes: 8 additions & 0 deletions GroomWise.Application/Events/DeleteAppointmentEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (C) 2023 Russell Camo (Russkyc).- All Rights Reserved
//
// Unauthorized copying or redistribution of all files, in source and binary forms via any medium
// without written, signed consent from the author is strictly prohibited.

namespace GroomWise.Application.Events;

public record DeleteAppointmentEvent();
25 changes: 25 additions & 0 deletions GroomWise.Application/Extensions/TimeExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (C) 2023 Russell Camo (Russkyc).- All Rights Reserved
//
// Unauthorized copying or redistribution of all files, in source and binary forms via any medium
// without written, signed consent from the author is strictly prohibited.

using GroomWise.Domain.Entities;

namespace GroomWise.Application.Extensions;

public static class TimeExtensions
{
public static bool IsBetween(this TimeOnly target, TimeOnly start, TimeOnly end)
{
if (start <= end)
{
return start <= target && target <= end;
}
return start <= target || target <= end;
}

public static bool IsOverlapping(this Appointment appointment, TimeOnly start, TimeOnly end)
{
return appointment.StartTime < end && appointment.EndTime > start;
}
}
11 changes: 1 addition & 10 deletions GroomWise.Application/GroomWise.Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
<PackageReference Include="Injectio" Version="2.6.2" />
<PackageReference Include="Lombok.NET" Version="2.1.3" />
<PackageReference Include="Mapster" Version="7.3.0" />
<PackageReference Include="MvvmGen.PureCodeGeneration" Version="1.2.1">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -24,15 +24,6 @@
<ProjectReference Include="..\GroomWise.Infrastructure\GroomWise.Infrastructure.csproj" />











</ItemGroup>


Expand Down
35 changes: 19 additions & 16 deletions GroomWise.Application/Observables/ObservableAppointment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,42 @@
// Unauthorized copying or redistribution of all files, in source and binary forms via any medium
// without written, signed consent from the author is strictly prohibited.

using CommunityToolkit.Mvvm.ComponentModel;
using GroomWise.Domain.Enums;
using Lombok.NET;
using Swordfish.NET.Collections;

namespace GroomWise.Application.Observables;

[NotifyPropertyChanged]
public partial class ObservableAppointment
public partial class ObservableAppointment : ObservableObject
{
[Property]
[ObservableProperty]
private Guid _id;

[Property]
private DateOnly? _date;
[ObservableProperty]
private DateTime _date;

[Property]
private TimeOnly? _startTime;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(TimeSpan))]
private TimeOnly _startTime;

[Property]
private TimeOnly? _endTime;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(TimeSpan))]
private TimeOnly _endTime;

[Property]
public string TimeSpan => $"{StartTime} - {EndTime}";

[ObservableProperty]
private AppointmentStatus? _status;

[Property]
[ObservableProperty]
private ObservablePet? _pet;

[Property]
private ObservableCustomer? _customer;
[ObservableProperty]
private ObservableCustomer _customer;

[Property]
[ObservableProperty]
private ConcurrentObservableCollection<ObservableEmployee>? _employees = new();

[Property]
[ObservableProperty]
private ConcurrentObservableCollection<ObservableAppointmentService>? _services = new();
}
13 changes: 3 additions & 10 deletions GroomWise.Application/Observables/ObservableAppointmentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,12 @@
// Unauthorized copying or redistribution of all files, in source and binary forms via any medium
// without written, signed consent from the author is strictly prohibited.

using MvvmGen;
using CommunityToolkit.Mvvm.ComponentModel;

namespace GroomWise.Application.Observables;

[ViewModel]
public partial class ObservableAppointmentService
public partial class ObservableAppointmentService : ObservableObject
{
[Property]
[PropertyCallMethod(nameof(ServiceChanged))]
[ObservableProperty]
private ObservableGroomingService? _groomingService;

private void ServiceChanged()
{
OnPropertyChanged(nameof(GroomingService.TimeSpan));
}
}
20 changes: 9 additions & 11 deletions GroomWise.Application/Observables/ObservableCustomer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,31 @@
// Unauthorized copying or redistribution of all files, in source and binary forms via any medium
// without written, signed consent from the author is strictly prohibited.

using GroomWise.Domain.Entities;
using Lombok.NET;
using CommunityToolkit.Mvvm.ComponentModel;
using Swordfish.NET.Collections;

namespace GroomWise.Application.Observables;

[NotifyPropertyChanged]
public partial class ObservableCustomer
public partial class ObservableCustomer : ObservableObject
{
[Property]
[ObservableProperty]
private Guid _id;

[Property]
[ObservableProperty]
private string _fullName;

[Property]
[ObservableProperty]
private string _address;

[Property]
[ObservableProperty]
private string _contactNumber;

[Property]
[ObservableProperty]
private string _email;

[Property]
[ObservableProperty]
private ConcurrentObservableCollection<ObservableAppointment> _appointments = new();

[Property]
[ObservableProperty]
private ConcurrentObservableCollection<ObservablePet> _pets = new();
}
39 changes: 21 additions & 18 deletions GroomWise.Application/Observables/ObservableEmployee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,51 @@
// Unauthorized copying or redistribution of all files, in source and binary forms via any medium
// without written, signed consent from the author is strictly prohibited.

using CommunityToolkit.Mvvm.ComponentModel;
using GroomWise.Domain.Entities;
using Lombok.NET;
using Swordfish.NET.Collections;

namespace GroomWise.Application.Observables;

[NotifyPropertyChanged]
public partial class ObservableEmployee
public partial class ObservableEmployee : ObservableObject
{
[Property]
[ObservableProperty]
private Guid _id;
public string FullName => $"{FirstName} {LastName}";

[Property]
[ObservableProperty]
private string? _prefix;

[Property]
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(FullName))]
private string? _firstName;

[Property]
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(FullName))]
private string? _middleName;

[Property]
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(FullName))]
private string? _lastName;

[Property]
[ObservableProperty]
private string? _suffix;

[Property]
[ObservableProperty]
private string _address;

[Property]
[ObservableProperty]
private string _contactNumber;

[Property]
[ObservableProperty]
private string _email;

[Property]
private IList<Pet>? _pets;
[ObservableProperty]
private ConcurrentObservableCollection<ObservablePet>? _pets = new();

[Property]
private IList<Appointment>? _appointments;
[ObservableProperty]
private ConcurrentObservableCollection<ObservableAppointment>? _appointments = new();

[Property]
private IList<Role>? _roles;
[ObservableProperty]
private ConcurrentObservableCollection<Role>? _roles = new();
}
18 changes: 9 additions & 9 deletions GroomWise.Application/Observables/ObservableGroomingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
// Unauthorized copying or redistribution of all files, in source and binary forms via any medium
// without written, signed consent from the author is strictly prohibited.

using MvvmGen;
using CommunityToolkit.Mvvm.ComponentModel;

namespace GroomWise.Application.Observables;

[ViewModel]
public partial class ObservableGroomingService
public partial class ObservableGroomingService : ObservableObject
{
[Property]
[ObservableProperty]
private Guid _id;

[Property]
[ObservableProperty]
private string? _type;

[Property]
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(TimeSpan))]
private double _hourSpan;

[Property]
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(TimeSpan))]
private double _minuteSpan;

[PropertyInvalidate(nameof(HourSpan), nameof(MinuteSpan))]
public TimeSpan TimeSpan =>
new TimeSpan().Add(TimeSpan.FromHours(HourSpan)).Add(TimeSpan.FromMinutes(MinuteSpan));

[Lombok.NET.Property]
[ObservableProperty]
private string? _description;
}
13 changes: 6 additions & 7 deletions GroomWise.Application/Observables/ObservableNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@
// Unauthorized copying or redistribution of all files, in source and binary forms via any medium
// without written, signed consent from the author is strictly prohibited.

using CommunityToolkit.Mvvm.ComponentModel;
using GroomWise.Domain.Enums;
using MvvmGen;

namespace GroomWise.Application.Observables;

[ViewModel]
public partial class ObservableNotification
public partial class ObservableNotification : ObservableObject
{
[Property]
[ObservableProperty]
private object? _icon;

[Property]
[ObservableProperty]
private string? _title;

[Property]
[ObservableProperty]
private string? _description;

[Property]
[ObservableProperty]
private NotificationType? _type;
}
17 changes: 7 additions & 10 deletions GroomWise.Application/Observables/ObservablePet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,24 @@
// Unauthorized copying or redistribution of all files, in source and binary forms via any medium
// without written, signed consent from the author is strictly prohibited.

using GroomWise.Domain.Entities;
using Lombok.NET;
using CommunityToolkit.Mvvm.ComponentModel;

namespace GroomWise.Application.Observables;

[NotifyPropertyChanged]
public partial class ObservablePet
public partial class ObservablePet : ObservableObject
{
[Property]
[ObservableProperty]
private Guid _id;

[Property]
[ObservableProperty]
private string? _name;

[Property]
[ObservableProperty]
private int? _age;

[Property]
[ObservableProperty]
private string? _breed;

[Property]
[ObservableProperty]
private string? _gender;

}
13 changes: 6 additions & 7 deletions GroomWise.Application/Observables/ObservableProduct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@
// Unauthorized copying or redistribution of all files, in source and binary forms via any medium
// without written, signed consent from the author is strictly prohibited.

using Lombok.NET;
using CommunityToolkit.Mvvm.ComponentModel;

namespace GroomWise.Application.Observables;

[NotifyPropertyChanged]
public partial class ObservableProduct
public partial class ObservableProduct : ObservableObject
{
[Property]
[ObservableProperty]
private Guid _id;

[Property]
[ObservableProperty]
private string? _productName;

[Property]
[ObservableProperty]
private string? _productDescription;

[Property]
[ObservableProperty]
private int _quantity;
}
Loading

0 comments on commit cd2c5fe

Please sign in to comment.