private void CreateNotif(SystemUser fromSystemUser, string notifType, int toSystemUserId) { var model = new Notification { SystemUserId = toSystemUserId, CreatedOn = DateTime.UtcNow, CreatedBy = fromSystemUser.SystemUserId, SystemUserType = Constant.USERTYPE_ADVISER, NotificationType = notifType, IsShowed = false, RegardingId = fromSystemUser.BusinessId, Message = string.Empty }; _notificationRepository.Insert(model); _busInstance.Publish(new NotificationAdded { NotificationType = notifType, SystemUserID = toSystemUserId, SystemUserType = Constant.USERTYPE_ADVISER, CreatedOn = DateTime.UtcNow, IsShowed = false, CreatedBy = fromSystemUser.SystemUserId, }); }
private void CreateNotif(int systemUserId, int createdBy, string notifType, string message) { var model = new Notification { SystemUserId = systemUserId, CreatedOn = DateTime.Now, CreatedBy = createdBy, SystemUserType = Constant.USERTYPE_CONTACT, NotificationType = notifType, IsShowed = false, Message = message }; _notificationRepository.Insert(model); _busInstance.Publish(new NotificationAdded { NotificationType = notifType, SystemUserID = systemUserId, SystemUserType = Constant.USERTYPE_CONTACT, CreatedOn = DateTime.UtcNow, IsShowed = false, CreatedBy = createdBy, Message = message }); }
private void CreateNotif(SystemUser createdSystemUser, string notifType) { var mentors = _businessToBusinessRepository.GetPagedList( predicate: a => a.BusinessId2 == createdSystemUser.BusinessId && a.IsActive == true && a.Business1.EduBusinessType != (int)EduBusinessType.Admin, pageSize: int.MaxValue, include: a => a.Include(b => b.Business1).ThenInclude(b => b.SystemUser)).Items; foreach (var mentor in mentors) { var mentorSystemUser = mentor.Business1.SystemUser.FirstOrDefault(); if (mentorSystemUser != null) { var model = new Notification { SystemUserId = mentorSystemUser.SystemUserId, CreatedOn = DateTime.Now, CreatedBy = createdSystemUser.SystemUserId, SystemUserType = Constant.USERTYPE_ADVISER, NotificationType = notifType, IsShowed = false, RegardingId = createdSystemUser.SystemUserId }; _notificationRepository.Insert(model); _busInstance.Publish(new NotificationAdded { NotificationType = notifType, SystemUserID = mentorSystemUser.SystemUserId, SystemUserType = Constant.USERTYPE_ADVISER, CreatedOn = DateTime.UtcNow, IsShowed = false, CreatedBy = createdSystemUser.SystemUserId, }); } } }
private void CreateNotif(SystemUser createdSystemUser, string notifType, int goalId, MentifiGoalProgress goalProgress) { var mentors = _businessToBusinessRepository.GetPagedList( predicate: a => a.BusinessId2 == createdSystemUser.BusinessId && a.IsActive == true && a.Business1.EduBusinessType != (int)EduBusinessType.Admin, include: a => a.Include(b => b.Business1).ThenInclude(b => b.SystemUser), pageSize: int.MaxValue).Items; MentifiGoalProgress lastGoalProgress = null; EduUniversity eduUniversity = null; Resource resource = null; var goal = _goalRepository.GetFirstOrDefault(predicate: a => a.MentifiGoalId == goalId, include: a => a.Include(b => b.MentifiGoalProgress)); if (goal != null) { lastGoalProgress = goal.MentifiGoalProgress.OrderByDescending(a => a.MentifiGoalProgressId) .FirstOrDefault(); eduUniversity = _universityRepository.GetFirstOrDefault(predicate: a => a.BusinessId == (createdSystemUser.Business.UniversityId ?? createdSystemUser.BusinessId)); resource = _resourceRepository.GetAll( a => a.ResourceName == "Mentifi_Message_GoalProgressNotification_Subject").GetAwaiter().GetResult().FirstOrDefault(); } foreach (var mentor in mentors) { var mentorSystemUser = mentor.Business1.SystemUser.FirstOrDefault(); if (mentorSystemUser != null) { var model = new Notification { SystemUserId = mentorSystemUser.SystemUserId, CreatedOn = DateTime.Now, CreatedBy = createdSystemUser.SystemUserId, SystemUserType = Constant.USERTYPE_ADVISER, NotificationType = notifType, IsShowed = false, RegardingId = createdSystemUser.SystemUserId, Message = string.Empty }; _notificationRepository.Insert(model); _busInstance.Publish(new NotificationAdded { NotificationType = notifType, SystemUserID = mentorSystemUser.SystemUserId, SystemUserType = Constant.USERTYPE_ADVISER, CreatedOn = DateTime.UtcNow, IsShowed = false, CreatedBy = createdSystemUser.SystemUserId, }); if (goal != null) { _emailApi.AddGoalProgress(new EmailParam() { Recipient = new[] { mentorSystemUser.EmailAddress }, SystemUserId = mentorSystemUser.SystemUserId, Payload = new[] { mentorSystemUser.FullName, createdSystemUser.FullName, goal.GoalDescription, lastGoalProgress?.ProgressPercentage.ToString(), goalProgress?.ProgressPercentage.ToString(), goalProgress?.Reason, _configuration["MentifiWebUrl"], eduUniversity.UniversityNameAlias, resource?.ResourceValue, eduUniversity.MenteeAlias } }).GetAwaiter().GetResult(); } } } }