using HospitalManagementSystem.Departments;
using HospitalManagementSystem.Dtos;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;

namespace HospitalManagementSystem.Doctors
{
    public class DoctorAppService : HospitalManagementSystemAppService, IDoctorAppService
    {
        private readonly IRepository<Doctor, Guid> _doctorRepository;
        public DoctorAppService(IRepository<Doctor, Guid> doctorRepository)
        {
            _doctorRepository = doctorRepository;
        }
        public async Task<List<DoctorDto>> GetAsync()
        {
            var doctorDtos = new List<DoctorDto>();
            var data = await _doctorRepository.GetListAsync();
            doctorDtos = ObjectMapper.Map<List<Doctor>, List<DoctorDto>>(data);
            return doctorDtos;
        }
        public async Task<DoctorDto> CreateAsync(CreateDoctorDto input)
        {
            var doctor = new Doctor(Guid.NewGuid(), input.FirstName, input.LastName, input.Gender, input.Mobile, input.Password, input.Designation, input.DepartmentId, input.Address, input.Email, input.DOB, input.Education);
            await _doctorRepository.InsertAsync(doctor);
            return ObjectMapper.Map<Doctor, DoctorDto>(doctor);
        }
    }
}
