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(); }
public ReplyController(ReplyRepository replyRepository, NotificationsIOSRepository _notifications) { this._replyRepository = replyRepository; this._notifications = _notifications; }
public NotificationsIOSController(NotificationsIOSRepository repo) { this._repository = repo; }