private NotificationDto CreateNotif(Account account, string userCode) { var sender = new BaseUser(); var potentialUser = _repository.GetByFilter <PotentialUser>(x => x.UserCode == userCode); var role = _repository.GetByFilter <UserRole>(x => x.Id == potentialUser.UserRoleId).Name; if (potentialUser == null || role == null) { return(null); } if (role == "Student") { sender = _repository.GetByFilter <Student>(x => x.PotentialUserId == potentialUser.Id); } if (role == "Professor") { sender = _repository.GetByFilter <Professor>(x => x.PotentialUserId == potentialUser.Id); } var notification = new NotificationDto { ReciverId = Guid.Empty, Title = "New post on wall.", Body = sender.LastName + ' ' + sender.FirstName + " has posted on the wall.", IsRead = false, SenderId = account.PotentialUserId, }; _notificationLogic.Create(notification); return(notification); }
private void CreateNotification(Feedback feedback) { var student = _repository.GetByFilter <Student>(x => x.Id == feedback.StudentId); var prof = _repository.GetByFilter <Professor>(x => x.Id == feedback.ProfessorId); var body = ""; var sender = Guid.Empty; if (student == null) { body = "Anonymous Feedback"; sender = Guid.Empty; } else { body = student.LastName + ' ' + student.FirstName + " left feedback for you"; sender = student.PotentialUserId; } var notification = new NotificationDto { Title = "New feedback", Body = body, IsRead = false, ReciverId = prof.PotentialUserId, SenderId = sender, ItemId = feedback.Id }; _notificationLogic.Create(notification); }
private NotificationDto CreateNotification(CommentDto commentDto, Guid id) { var sender = new BaseUser(); var account = _repository.GetByFilter <Account>(x => x.UserCode == commentDto.UserCode); var potentialUser = _repository.GetByFilter <PotentialUser>(x => x.UserCode == commentDto.UserCode); var post = _repository.GetByFilter <Post>(x => x.Id == commentDto.PostId); var reciver = _repository.GetByFilter <Account>(x => x.Id == post.AccountId); var role = _repository.GetByFilter <UserRole>(x => x.Id == potentialUser.UserRoleId).Name; if (role == "Student") { sender = _repository.GetByFilter <Student>(x => x.PotentialUserId == potentialUser.Id); } if (role == "Professor") { sender = _repository.GetByFilter <Professor>(x => x.PotentialUserId == potentialUser.Id); } var notification = new NotificationDto { Title = "New comment", Body = sender.LastName + ' ' + sender.FirstName + " added a comment at your post", IsRead = false, ReciverId = reciver.PotentialUserId, SenderId = account.PotentialUserId, ItemId = id }; _notificationLogic.Create(notification); return(notification); }
public OperationResultInfo AddNotification(NotificationReceiveModel notification) { try { _notificationLogic.Create(notification); return(new OperationResultInfo() { ErrorInfo = string.Empty, OperationResult = OperationsResults.Successfully, ToListener = ListenerType.NotificationListListener }); } catch (Exception ex) { return(new OperationResultInfo() { ErrorInfo = ex.Message, OperationResult = OperationsResults.Unsuccessfully, ToListener = ListenerType.NotificationListListener }); } }
public Grade Add(GradeDto gradeDto) { var grade = new Grade() { StudentId = gradeDto.StudentId, ProfId = gradeDto.ProfId, CourseId = gradeDto.CourseId, Value = gradeDto.Value, CategoryId = gradeDto.CategoryId, Id = Guid.NewGuid(), Date = DateTime.Now }; _repository.Insert(grade); _repository.Save(); var notification = CreateNotification(grade); _notificationLogic.Create(notification); var final = _finalGradeLogic.ComputeFinalGrade(gradeDto.CourseId, gradeDto.StudentId); return(grade); }
public IActionResult AddNotification(NotificationDto notification) { var result = _notificationLogic.Create(notification); return(Ok(result)); }