From 7d1a10a281424acfd8743762c1ee76e40217fc73 Mon Sep 17 00:00:00 2001 From: anperederi Date: Fri, 23 Feb 2024 09:02:58 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Update=20Stubbed=20Files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/StubbedDtoLib/AthleteStubDto.cs | 132 +------------------------ src/StubbedDtoLib/StubbedDtoLib.csproj | 6 +- 2 files changed, 5 insertions(+), 133 deletions(-) diff --git a/src/StubbedDtoLib/AthleteStubDto.cs b/src/StubbedDtoLib/AthleteStubDto.cs index 1b501c7..67876f2 100644 --- a/src/StubbedDtoLib/AthleteStubDto.cs +++ b/src/StubbedDtoLib/AthleteStubDto.cs @@ -1,135 +1,7 @@ -using System.ComponentModel; -using Dto; -using Share; +using Shared; namespace StubbedDtoLib; public class AthleteStubDto : IAthleteService { - private static List AthleteList = new List() - { - new AthleteDto { IdAthlete = 1, Username = "Doe", LastName = "John", FirstName = "Doe", Email = "john.doe@example.com", Password = "password123", Sexe = "M", Lenght = 1.80, Weight = 75, DateOfBirth = new DateTime(), IsCoach = true }, - new AthleteDto { IdAthlete = 2, Username = "Smith", LastName = "Jane", FirstName = "Smith", Email = "jane.smith@example.com", Password = "secure456", Sexe = "F", Lenght = 1.65, Weight = 60, DateOfBirth = new DateTime(), IsCoach = false }, - new AthleteDto { IdAthlete = 3, Username = "Martin", LastName = "Paul", FirstName = "Martin", Email = "paul.martin@example.com", Password = "super789", Sexe = "M", Lenght = 1.75, Weight = 68, DateOfBirth = new DateTime(), IsCoach = true }, - new AthleteDto { IdAthlete = 4, Username = "Brown", LastName = "Anna", FirstName = "Brown", Email = "anna.brown@example.com", Password = "test000", Sexe = "M", Lenght = 1.70, Weight = 58, DateOfBirth = new DateTime(), IsCoach = false }, - new AthleteDto { IdAthlete = 5, Username = "Lee", LastName = "Bruce", FirstName = "Lee", Email = "bruce.lee@example.com", Password = "hello321", Sexe = "M", Lenght = 2.0, Weight = 90, DateOfBirth = new DateTime(), IsCoach = false } - }; - - public async Task> GetAllAthletesAsync() - { - return AthleteList; - } - - public async Task> GetSomeAthletesAsync(int index, int count) - { - return AthleteList.Skip(count*index).Take(count); - } - - public async Task GetAthleteByIdAsync(int id) => AthleteList.Find(a => a.IdAthlete == id); - - public async Task> GetAthleteByUsernameAsync(string username, int index, int count) - { - return AthleteList.FindAll(a => a.Username.Contains(username, StringComparison.OrdinalIgnoreCase)).Skip(index*count).Take(count); - } - - public async Task> GetAthletesByEmailAsync(string email, int index, int count) - { - return AthleteList.FindAll(a => a.Email.Contains(email, StringComparison.OrdinalIgnoreCase)).Skip(index*count).Take(count); - } - - public async Task> GetAthletesByFirstNameAsync(string firstName, int index, int count) - { - return AthleteList.FindAll(a => a.FirstName.Contains(firstName, StringComparison.OrdinalIgnoreCase)).Skip(index*count).Take(count); - } - - public async Task> GetAthletesByLastNameAsync(string lastName, int index, int count) - { - return AthleteList.FindAll(a => a.LastName.Contains(lastName, StringComparison.OrdinalIgnoreCase)).Skip(index*count).Take(count); - } - - public async Task> GetAthletesBySexeAsync(string sexe, int index, int count) - { - return AthleteList.FindAll(a => a.Sexe.Contains(sexe, StringComparison.OrdinalIgnoreCase)).Skip(index*count).Take(count); - } - - public async Task> GetAthletesByLenghtAsync(double lenght, int index, int count) - { - return AthleteList.FindAll(a => a.Lenght == lenght).Skip(index*count).Take(count); - } - - public async Task> GetAthletesByWeightAsync(float weight, int index, int count) - { - return AthleteList.FindAll(a => a.Weight == weight).Skip(index*count).Take(count); - } - - public async Task> GetAthletesByDateOfBirthAsync(DateTime dateOfBirth, int index, int count) - { - return AthleteList.FindAll(a => a.DateOfBirth == dateOfBirth).Skip(index*count).Take(count); - } - - public async Task> GetAthletesByIsCoachAsync(bool isCoach, int index, int count) - { - return AthleteList.FindAll(a => a.IsCoach == isCoach).Skip(index*count).Take(count); - } - - public async Task AddAthleteAsync(AthleteDto athlete) - { - var newAthlete = new AthleteDto() - { - IdAthlete = AthleteList.Max(a => a.IdAthlete) + 1, - Username = athlete.Username, - LastName = athlete.LastName, - FirstName = athlete.FirstName, - Email = athlete.Email, - Password = athlete.Password, - Sexe = athlete.Sexe, - Lenght = athlete.Lenght, - Weight = athlete.Weight, - DateOfBirth = athlete.DateOfBirth, - IsCoach = athlete.IsCoach - }; - AthleteList.Add(newAthlete); - return newAthlete; - } - - public async Task UpdateAthleteAsync(int id, AthleteDto athlete) - { - var theId = AthleteList.FindIndex(a => a.IdAthlete == id); - if (theId >= 0) - { - var a = AthleteList[theId]; - - a.Username = athlete.Username; - a.LastName = athlete.LastName; - a.FirstName = athlete.FirstName; - a.Email = athlete.Email; - a.Password = athlete.Password; - a.Sexe = athlete.Sexe; - a.Lenght = athlete.Lenght; - a.Weight = athlete.Weight; - a.DateOfBirth = athlete.DateOfBirth; - a.IsCoach = athlete.IsCoach; - - AthleteList[theId] = a; - - return a; - } - else - { - return null; - } - } - - public async Task DeleteAthleteAsync(int id) - { - var theId = AthleteList.FindIndex(a => a.IdAthlete == id); - if (theId >= 0) - { - AthleteList.RemoveAt(theId); - return true; - } else - { - return false; - } - } -} +} \ No newline at end of file diff --git a/src/StubbedDtoLib/StubbedDtoLib.csproj b/src/StubbedDtoLib/StubbedDtoLib.csproj index 581f491..aa1b3e2 100644 --- a/src/StubbedDtoLib/StubbedDtoLib.csproj +++ b/src/StubbedDtoLib/StubbedDtoLib.csproj @@ -1,8 +1,8 @@  - - - + + +