Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

database api: notification id was missing

  • Loading branch information...
commit 12ccf4bcfa28c6ee4b10acbf6acd47f335eae84a 1 parent a46452a
@Martikos Martikos authored
View
20 App_Code/DataServices/NotificationDataService.cs
@@ -44,18 +44,20 @@ public static List<Notification> getNotifications(String userId)
{
if (!ids.Contains(ReceiverId))
{
+ int uid = (int)reader[ColumnNames.NotificationId];
string Message = (string)reader[ColumnNames.Message];
int NotificationId = (int)reader[ColumnNames.NotificationId];
DateTime Date = (DateTime)reader[ColumnNames.Date];
- returnList.Add(new Notification(Message, SenderId, ReceiverId, Date));
+ returnList.Add(new Notification(uid, Message, SenderId, ReceiverId, Date));
ids.Add(ReceiverId);
}
} else if(ReceiverId.ToString().Equals(userId)) {
if(!ids.Contains(SenderId)) {
+ int uid = (int)reader[ColumnNames.NotificationId];
string Message = (string)reader[ColumnNames.Message];
int NotificationId = (int)reader[ColumnNames.NotificationId];
DateTime Date = (DateTime)reader[ColumnNames.Date];
- returnList.Add(new Notification(Message, SenderId, ReceiverId, Date));
+ returnList.Add(new Notification(uid, Message, SenderId, ReceiverId, Date));
ids.Add(SenderId);
}
}
@@ -86,13 +88,25 @@ public static List<Notification> getConversation(String SenderId, String Receive
int NotificationId = (int)reader[ColumnNames.NotificationId];
string Message = (string)reader[ColumnNames.Message];
DateTime date = (DateTime)reader[ColumnNames.Date];
- returnList.Add(new Notification(Message, senderId, receiverId, date));
+ returnList.Add(new Notification(NotificationId, Message, senderId, receiverId, date));
}
conn.Close();
return returnList;
}
+ public static Boolean deleteNotification(String id)
+ {
+ SqlConnection conn = DBConnector.getSqlConnection();
+ conn.Open();
+ SqlCommand cmd = new SqlCommand("DELETE FROM Notifications where NotificationId = @NotificationId", conn);
+ cmd.Parameters.AddWithValue("@NotificationId", id);
+
+ int rowsAffected = cmd.ExecuteNonQuery();
+ conn.Close();
+ return (rowsAffected > 0);
+ }
+
public static void saveNotification(Notification notification)
{
SqlConnection conn = DBConnector.getSqlConnection();
View
9 App_Code/Entities/Notification.cs
@@ -22,6 +22,15 @@ public Notification(string message, Guid senderId, Guid recieverId, DateTime dat
this.sentDate = date;
}
+ public Notification(int id, string message, Guid senderId, Guid recieverId, DateTime date)
+ {
+ this.id = id;
+ this.message = message;
+ this.senderId = senderId;
+ this.recieverId = recieverId;
+ this.sentDate = date;
+
+ }
public static Notification createNewNotification(Guid sender, Guid reciever) {
return new Notification("", sender, reciever, DateTime.Now);
Please sign in to comment.
Something went wrong with that request. Please try again.