/// <summary> /// /// </summary> /// <param name="notification"></param> public void UpdateNotification(Notification notification) { if (notification != null) { var query = GameSchoolEntities.Notifications.Where(n => n.NotificationId == notification.NotificationId); var notificationToUpdate = query.FirstOrDefault(); notificationToUpdate.Description = notification.Description; notificationToUpdate.IsRead = notification.IsRead; notificationToUpdate.Url = notification.Url; Save(); } }
/// <summary> /// Create a new user notification. /// </summary> /// <param name="text"></param> /// <param name="url"></param> /// <param name="userInfoId"></param> public void CreateNotification(string text, string url, int userInfoId) { if (!string.IsNullOrEmpty(text) && userInfoId > 0) { var notification = new Notification(); notification.Description = text; notification.IsRead = false; notification.UserInfoId = userInfoId; notification.Url = url; notification.CreateDateTime = DateTime.Now; GameSchoolEntities.Notifications.AddObject(notification); Save(); } }
private FakeObjectSet<Notification> CreateNotificationList(int userId, int amount) { FakeObjectSet<Notification> notificationList = new FakeObjectSet<Notification>(); for (int i = 0; i <= amount; i++) { var expected = new Notification(); expected.NotificationId = i+1; expected.UserInfoId = userId; expected.CreateDateTime = DateTime.Now; expected.Url = "http://www.visir.is"; expected.IsRead = false; expected.Description = string.Format("Tester {0} description.", i+1); notificationList.AddObject(expected); } return notificationList; }