public async Task SaveNotification(NotificationM notification) { var newObj = _mapper.Map <Notification>(notification); await _dbContext.Notifications.AddAsync(newObj); await _dbContext.SaveChangesAsync(); }
public async Task <bool> Handle(SendNotificationRequest message, IOutputPort <SendNotificationResponse> outputPort) { var destinations = await _userRepository.GetAllMails(); var _not = new NotificationM(message.MessageContent, message.MessageSubject, destinations); await _mailSenderSrv.SendMail(message.MessageContent, message.MessageSubject, destinations); await _ntfRepository.SaveNotification(_not); return(true); }
public bool SetReadedNotification(NotificationM notification) { try { using (var sqlCmd = PluginInitialization._app.SqlWork(true)) { sqlCmd.sql = @"UPDATE notification.notification_users SET seen_datetime=now() WHERE notification_gid = @notification_gid AND user_gid = @user_gid;"; sqlCmd.AddParam(new Params("@notification_gid", notification.Gid, NpgsqlDbType.Integer)); sqlCmd.AddParam(new Params("@user_gid", PluginInitialization._app.user_info.id_user, NpgsqlDbType.Integer)); sqlCmd.ExecuteNonQuery(); return(true); } } catch { return(false); } }
public bool SetFavorite(NotificationM notification, bool value) { try { using (var sqlCmd = PluginInitialization._app.SqlWork(true)) { sqlCmd.sql = @"UPDATE notification.notification_users SET favorite=@favorite WHERE notification_gid = @notification_gid AND user_gid = @user_gid;"; sqlCmd.AddParam(new Params("@favorite", value, NpgsqlDbType.Boolean)); sqlCmd.AddParam(new Params("@notification_gid", notification.Gid, NpgsqlDbType.Integer)); sqlCmd.AddParam(new Params("@user_gid", PluginInitialization._app.user_info.id_user, NpgsqlDbType.Integer)); sqlCmd.ExecuteNonQuery(); return(true); } } catch { return(false); } }
public NotificationVM(NotificationM notification, NotificationRepository repo) { _notification = notification; _repo = repo; }