public static ImmutableAnimalModel RenameAnimal(this ImmutableAnimalModel animal, string newName) { var animalModel = new AnimalModel { Name = newName, Description = animal.Description, Color = animal.Color, Age = animal.Age, BirthDate = animal.BirthDate }; return(new ImmutableAnimalModel(animalModel)); }
public static ImmutableAnimalModel SetBirthday(this ImmutableAnimalModel animal, DateTime newBirthday) { var animalModel = new AnimalModel { Name = animal.Name, Description = animal.Description, Color = animal.Color, Age = animal.Age, BirthDate = newBirthday }; return(new ImmutableAnimalModel(animalModel)); }
public static ImmutableAnimalModel ChangeColor(this ImmutableAnimalModel animal, string newColor) { var animalModel = new AnimalModel { Name = animal.Name, Description = animal.Description, Color = newColor, Age = animal.Age, BirthDate = animal.BirthDate }; return(new ImmutableAnimalModel(animalModel)); }
public static ImmutableAnimalModel CalculateAge(this ImmutableAnimalModel animal) { var calculatedAge = DateTime.Today.Year - animal.BirthDate.Year; var animalModel = new AnimalModel { Name = animal.Name, Description = animal.Description, Color = animal.Color, Age = calculatedAge, BirthDate = animal.BirthDate }; return(new ImmutableAnimalModel(animalModel)); }