/// <summary> /// Add notification about action to db. /// </summary> /// <param name="userOneId">user one id.</param> /// <param name="userTwoId">user two id.</param> /// <param name="action">action.</param> /// <param name="actionTime">time of action.</param> /// <returns>true if operations success; otherwise, false.</returns> public static bool AddNotification(int userOneId, int userTwoId, UserActions action, DateTime actionTime) { using (var DBcontext = new LinqToSqlDataContext()) { // new notification Notification newNotification; switch (action) { case UserActions.AcceptFriendship: newNotification = new Notification { user_one = userOneId, user_two = userTwoId, time = actionTime, accept_friendship = true }; break; case UserActions.RejectFriendship: newNotification = new Notification { user_one = userOneId, user_two = userTwoId, time = actionTime, reject_friendship = true }; break; case UserActions.SendFriendshipRequest: newNotification = new Notification { user_one = userOneId, user_two = userTwoId, time = actionTime, send_friendship = true }; break; case UserActions.CancelFriendshipRequest: newNotification = new Notification { user_one = userOneId, user_two = userTwoId, time = actionTime, cancel_friendship = true }; break; case UserActions.RemoveFromFriends: newNotification = new Notification { user_one = userOneId, user_two = userTwoId, time = actionTime, remove_friend = true }; break; default: return false; } DBcontext.Notifications.InsertOnSubmit(newNotification); try { DBcontext.SubmitChanges(); return true; } catch (Exception e) { log.Error(e); return false; } } }
partial void DeleteNotification(Notification instance);
partial void UpdateNotification(Notification instance);
partial void InsertNotification(Notification instance);
private void detach_Notifications1(Notification entity) { this.SendPropertyChanging(); entity.User1 = null; }
private void attach_Notifications(Notification entity) { this.SendPropertyChanging(); entity.User = this; }