Example #1
0
        public void AddAppointment(Guid medicId, int duration, DateTime date, string adminId)
        {
            Guid adminIdGuid = Guid.Empty;

            if (!Guid.TryParse(adminId, out adminIdGuid))
            {
                throw new Exception("Invalid Guid Format");
            }
            var admin = adminRepository.GetAdminByUserId(adminIdGuid);

            if (admin == null)
            {
                throw new EntityNotFoundException(adminIdGuid);
            }

            var medic = medicRepository.GetMedicByID(medicId);

            var appointment = appointmentRepository.Add(new Appointment()
            {
                Id       = Guid.NewGuid(),
                Duration = duration,
                Date     = date,
                Admin    = admin,
                Medic    = medic
            });
        }