Esempio n. 1
0
        public static MedicalPractice UpdateRoom(this MedicalPractice medPractice, Room updatedRoom)
        {
            var oldRoomList = medPractice.Rooms.ToList();
            var newRoomList = new List <Room>();

            foreach (var room in oldRoomList)
            {
                if (room.Id != updatedRoom.Id)
                {
                    newRoomList.Add(room);
                }
                else
                {
                    newRoomList.Add(updatedRoom);
                }
            }

            var updatedVersion = medPractice.Version + 1;

            return(new MedicalPractice(newRoomList,
                                       medPractice.Name,
                                       updatedVersion,
                                       medPractice.Id,
                                       medPractice,
                                       medPractice.HoursOfOpening));
        }
Esempio n. 2
0
 public MedicalPractice(IEnumerable <Room> rooms, string name, uint version, Guid id,
                        MedicalPractice previousVersion, HoursOfOpening hoursOfOpening)
 {
     Rooms           = rooms.ToList();
     Name            = name;
     Version         = version;
     Id              = id;
     PreviousVersion = previousVersion;
     HoursOfOpening  = hoursOfOpening;
 }
Esempio n. 3
0
        public static MedicalPractice SetNewHoursOfOpening(this MedicalPractice medPractice, HoursOfOpening newHoursOfOpening)
        {
            var updatedVersion = medPractice.Version + 1;

            return(new MedicalPractice(medPractice.Rooms,
                                       medPractice.Name,
                                       updatedVersion,
                                       medPractice.Id,
                                       medPractice,
                                       newHoursOfOpening));
        }
Esempio n. 4
0
        public static MedicalPractice RemoveRoom(this MedicalPractice medPractice, Guid roomToRemove)
        {
            var updatedRoomList = medPractice.Rooms.Where(room => room.Id != roomToRemove).ToList();
            var updatedVersion  = medPractice.Version + 1;

            return(new MedicalPractice(updatedRoomList,
                                       medPractice.Name,
                                       updatedVersion,
                                       medPractice.Id,
                                       medPractice,
                                       medPractice.HoursOfOpening));
        }
Esempio n. 5
0
        public static MedicalPractice AddRoom(this MedicalPractice medPractice, Room newRoom)
        {
            var updatedRoomList = medPractice.Rooms.Concat(new List <Room> {
                newRoom
            }).ToList();
            var updatedVersion = medPractice.Version + 1;

            return(new MedicalPractice(updatedRoomList,
                                       medPractice.Name,
                                       updatedVersion,
                                       medPractice.Id,
                                       medPractice,
                                       medPractice.HoursOfOpening));
        }
 public ClientMedicalPracticeData(MedicalPractice practice)
     : this(practice.Rooms, practice.Name, practice.Version, practice.Id, practice.HoursOfOpening)
 {
 }