public async Task<int> Create(AppointmentCreateDTO model, string userId)
        {
            if (!await userManager.IsInRoleAsync(model.AgentId, AgentRole))
            {
                throw new NotAuthorizedException("Потребителят на който заявявате среща не е Брокер или не е намерен!");
            }
            if (!await unitOfWork.PropertiesBaseRepository.GetAll().AnyAsync(p => p.Id == model.PropertyId))
            {
                throw new ContentNotFoundException("Имотът, за който заявявате среща не е намерен в системата!");
            }
            if (!await userManager.IsInRoleAsync(userId, ClientRole))
            {
                throw new NotAuthorizedException("Потребителят от който заявявате среща не е намерен!");
            }

            Appointments appointment = new Appointments
            {
                AgentId = model.AgentId,
                PropertyId = model.PropertyId,
                AppointmentDate = model.AppointmentDate,
                AppointmentDescription = model.AppointmentDescription,
                IssuerUserId = userId
            };

            var appointmentId = await CreateAppointment(appointment);
            //Notify Agent for the appointment
            if (ConfigurationManager.AppSettings["AppStatus"] != "Developement")
            {
                var userInfo = await userManager.FindByIdAsync(userId);
                await SendEmailAndSmsNotificationToAgent(model.AgentId, model.PropertyId, userInfo.UserName, userInfo.Email, userInfo.PhoneNumber);
            }
            return appointmentId;
        }
        public ActionResult <AppointmentReadDTO> CreateAppointment(AppointmentCreateDTO appointmentCreateDTO)
        {
            //Creating the appointment

            var createAppointment = _mapper.Map <Appointment>(appointmentCreateDTO);

            if (createAppointment != null)
            {
                _repository.CreateAppointment(createAppointment);
            }
            else
            {
                return(BadRequest(createAppointment));
            }
            _repository.SaveChanges();


            //Returining the appointment
            var appointReadDTO = _mapper.Map <AppointmentReadDTO>(createAppointment);

            return(Ok(appointReadDTO));
        }