Skip to content

Commit

Permalink
refactor: Use expression body definition
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDave1999 committed Mar 18, 2024
1 parent 4298a63 commit 251ecec
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 41 deletions.
4 changes: 1 addition & 3 deletions src/Shared/Entities/Appointment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,5 @@ public class Appointment : BaseEntity, IAuditableEntity
/// </returns>
[Decompile]
public bool IsNotCanceled()
{
return AppointmentStatusId != (int)AppointmentStatus.Predefined.Canceled;
}
=> AppointmentStatusId != (int)AppointmentStatus.Predefined.Canceled;
}
12 changes: 3 additions & 9 deletions src/Shared/Entities/Common/SoftDeleteEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,13 @@ public abstract class SoftDeleteEntity : BaseEntity

[Decompile]
public string GetStatusName()
{
return IsDeleted ? StatusType.Inactive: StatusType.Active;
}
=> IsDeleted ? StatusType.Inactive: StatusType.Active;

[Decompile]
public bool IsActive()
{
return !IsDeleted;
}
=> !IsDeleted;

[Decompile]
public bool IsInactive()
{
return IsDeleted;
}
=> IsDeleted;
}
6 changes: 3 additions & 3 deletions src/Shared/Entities/Employee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Employee : SoftDeleteEntity, IAuditableEntity
public List<EmployeeSpecialty> EmployeeSpecialties { get; set; }

public bool IsSuperAdmin()
{
return User.UserRoles.Any(userRole => userRole.RoleId == (int)Role.Predefined.Superadmin);
}
=> User
.UserRoles
.Any(userRole => userRole.RoleId == (int)Role.Predefined.Superadmin);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,27 @@ public static class IEmployeeScheduleExtensions
/// Checks if the employee's schedule is in the morning.
/// </summary>
public static bool IsMorningSchedule(this IEmployeeSchedule employeeSchedule)
{
return employeeSchedule.MorningStartHour is not null &&
=> employeeSchedule.MorningStartHour is not null &&
employeeSchedule.MorningEndHour is not null;
}

/// <summary>
/// Checks if the employee's schedule is in the afternoon.
/// </summary>
public static bool IsAfternoonSchedule(this IEmployeeSchedule employeeSchedule)
{
return employeeSchedule.AfternoonStartHour is not null &&
=> employeeSchedule.AfternoonStartHour is not null &&
employeeSchedule.AfternoonEndHour is not null;
}

/// <summary>
/// Checks if the employee does not have morning and afternoon schedule.
/// </summary>
public static bool HasNotSchedule(this IEmployeeSchedule employeeSchedule)
{
return !employeeSchedule.IsMorningSchedule() &&
=> !employeeSchedule.IsMorningSchedule() &&
!employeeSchedule.IsAfternoonSchedule();
}

/// <summary>
/// Checks if the employee has a morning and afternoon schedule.
/// </summary>
public static bool HasFullSchedule(this IEmployeeSchedule employeeSchedule)
{
return employeeSchedule.IsMorningSchedule() &&
=> employeeSchedule.IsMorningSchedule() &&
employeeSchedule.IsAfternoonSchedule();
}
}
8 changes: 3 additions & 5 deletions src/Shared/Entities/OfficeSchedule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ public class OfficeSchedule : SoftDeleteEntity, IAuditableEntity

[Decompile]
public override string ToString()
{
return StartHour.GetHourWithoutSeconds() +
" - " +
EndHour.GetHourWithoutSeconds();
}
=> StartHour.GetHourWithoutSeconds() +
" - " +
EndHour.GetHourWithoutSeconds();
}
12 changes: 3 additions & 9 deletions src/Shared/Entities/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,11 @@ public class User : BaseEntity, IAuditableEntity
public List<UserRole> UserRoles { get; set; }

public bool IsUnverified()
{
return UserRoles.First().RoleId == (int)Role.Predefined.Unverified;
}
=> UserRoles.First().RoleId == (int)Role.Predefined.Unverified;

public bool IsVerified()
{
return !IsUnverified();
}
=> !IsUnverified();

public bool IsBasicUser()
{
return UserRoles.Any(userRole => userRole.RoleId == (int)Role.Predefined.BasicUser);
}
=> UserRoles.Any(userRole => userRole.RoleId == (int)Role.Predefined.BasicUser);
}

0 comments on commit 251ecec

Please sign in to comment.