Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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));
        }