// Create public CreateNewNotificationsResponse CreateNewNotification(CreateNewNotificationsRequest request) { var response = new CreateNewNotificationsResponse(); try { Guard.ArgNotNull(_unitOfWork.NotificationRepository, "_notificationRepo"); var notification = new Notification { Text = request.Text, DateCreated = DateTime.UtcNow, NotificationType_Id = request.Notification_Type_Id, User_Id = request.User_Id, User_FormsAuthId = request.User_Forms_AuthId }; _unitOfWork.NotificationRepository.Insert(notification); _unitOfWork.Save(); int newId = notification.Id; if (newId > 0) { response.Success = true; response.Id = newId; response.Text = notification.Text; response.NotificationTypeId = notification.NotificationType_Id; response.UserId = notification.User_Id; response.UserFormsAuthId = notification.User_FormsAuthId; Logger.LogInfo("Successfully created Notification Id: " + newId.ToString(), LogType.General); } } catch (Exception ex) { response.Success = false; response.FailureInformation = ex.Message; Logger.LogError("CreateNewNotification Method Failed", ex); } return response; }
/// <summary> /// Deprecated Method for adding a new object to the Notifications EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToNotifications(Notification notification) { base.AddObject("Notifications", notification); }
/// <summary> /// Create a new Notification object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="dateCreated">Initial value of the DateCreated property.</param> /// <param name="text">Initial value of the Text property.</param> /// <param name="notificationType_Id">Initial value of the NotificationType_Id property.</param> /// <param name="user_Id">Initial value of the User_Id property.</param> /// <param name="user_FormsAuthId">Initial value of the User_FormsAuthId property.</param> public static Notification CreateNotification(global::System.Int32 id, global::System.DateTime dateCreated, global::System.String text, global::System.Int32 notificationType_Id, global::System.Int32 user_Id, global::System.Guid user_FormsAuthId) { Notification notification = new Notification(); notification.Id = id; notification.DateCreated = dateCreated; notification.Text = text; notification.NotificationType_Id = notificationType_Id; notification.User_Id = user_Id; notification.User_FormsAuthId = user_FormsAuthId; return notification; }