private void OnUpdated(IAfterEntry <EventEntity, BiContext> evt) { var _notification = new NotificationsIOSRepository(evt.Context); var _dbNotification = evt.Context.Set <NotificationEntity>(); var _dbReport = evt.Context.Set <ReportEntity>(); var reportEvt = evt.Entity.Body as ReportUpdatedEvt; var report = _dbReport.Include(r => r.Company).Include(r => r.Week).Include(r => r.User).First(r => r.Id == reportEvt.Id); var users = this.UserFromReport(evt.Context, report); _dbNotification.Add(new NotificationEntity() { Body = new ReportUpdated() { Id = report.Id, CompanyId = report.CompanyId, UserId = report.UserId, WeekId = report.WeekId }, SenderId = evt.Entity.UserId, Receivers = users.Select(u => new ReceiverEntity() { UserId = u }).ToList() }); var message = "Se actualizó reporte de la empresa: " + report.Company.Name + " por el usuario: " + report.User.Name + " " + report.User.Lastname + " en la semana: " + report.Week.StartTime.ToString("dd MMM").ToUpper() + " al " + report.Week.EndTime.ToString("dd MMM yyyy").ToUpper(); _notification.SendNotification(users, message, report); evt.Context.SaveChanges(); }
private void onUpdated(IAfterEntry <EventEntity, BiContext> entry) { var db = entry.Context.Set <NotificationEntity>(); var dbPermission = entry.Context.Set <PermissionEntity>(); var eventBody = entry.Entity.Body as CompanyUpdatedEvt; var receivers = dbPermission.Where(p => p.CompanyId == eventBody.Id) .Select(p => p.UserId).Distinct().ToList(); var companyEntity = new NotificationEntity { SenderId = entry.Entity.UserId, Body = eventBody, Receivers = receivers.Select(uid => new ReceiverEntity { UserId = uid }).ToList() }; db.Add(companyEntity); entry.Context.SaveChanges(); }
private static void InsertedCheckFlags(IAfterEntry <Thing> e) => InsertedCheckFlags(e.Entity);
private static void InsertedTrue(IAfterEntry <Thing> e) => InsertedTrue(e.Entity);
private static void InsertedCheckFlags (IAfterEntry<Thing> e) => InsertedCheckFlags (e.Entity);
private static void InsertedTrue (IAfterEntry<Thing> e) => InsertedTrue (e.Entity);