public async Task AddEducator(CreateTenantEducatorDto input) { var isExist = await _tenantEducatorRepository.GetAll() .Where(x => x.EducatorId == input.EducatorId && x.TenantId == input.TenantId).ToListAsync(); if (isExist.Count != 0) { throw new Exception("Bu egitmen zaten ekli!"); } var tenant = await _tenantRepository.GetByIdAsync(input.TenantId); var model = new TenantEducator { EducatorId = input.EducatorId, TenantId = input.TenantId }; await _tenantEducatorRepository.AddAsync(model); await _notificationAppService.CreateNotify(new CreateNotificationDto { OwnerId = input.EducatorId, OwnerType = EntityType.Educator, SenderId = input.TenantId, SenderType = EntityType.Tenant, Title = "Ekleme isteği", Content = tenant.TenantName + " " + "sizi eğitmen olarak eklemek istiyor.", NotifyContentType = NotifyContentType.SubscribeRequest }); }
public async Task HandleSubscribeTenant(SubscribeDto input) { var relation = await _tenantEducatorRepository.GetAll() .FirstOrDefaultAsync(x => x.EducatorId == input.EducatorId && x.TenantId == input.TenantId); relation.IsAccepted = input.IsAccepted; await _tenantEducatorRepository.UpdateAsync(relation); var educator = await _educatorRepository.GetByIdAsync(input.EducatorId); if (input.IsAccepted) { await _notificationAppService.CreateNotify(new CreateNotificationDto { OwnerId = input.TenantId, OwnerType = EntityType.Tenant, SenderId = input.TenantId, SenderType = EntityType.Educator, Content = educator.Profession + " " + educator.Name + " " + educator.Surname + " " + "Eğitmen Ekleme Talebinizi Kabul Etti.", NotifyContentType = NotifyContentType.SubscribeResponse }); } }
public async Task <IActionResult> CreateNotify(CreateNotificationDto input) { await _notificationAppService.CreateNotify(input); return(Ok()); }