/// <summary> /// Logically delete to the status of notification table /// </summary> /// <param name="notification"></param> /// <returns> /// Return DB_SATUS /// </returns> public Constants.DB_STATUS Delete(Notification notification) { Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN; try { notificationObj = inventory.Notifications.Where(n => n.Id == notification.Id).First(); notificationObj.Status = 2; inventory.SaveChanges(); status = Constants.DB_STATUS.SUCCESSFULL; } catch (Exception e) { status = Constants.DB_STATUS.FAILED; } return status; }
/// <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="message">Initial value of the Message property.</param> /// <param name="createdDate">Initial value of the CreatedDate property.</param> /// <param name="status">Initial value of the Status property.</param> public static Notification CreateNotification(global::System.Int32 id, global::System.String message, global::System.DateTime createdDate, global::System.Int32 status) { Notification notification = new Notification(); notification.Id = id; notification.Message = message; notification.CreatedDate = createdDate; notification.Status = status; return notification; }
/// <summary> /// Update Notification data to Notification table /// </summary> /// <param name="notification"></param> /// <returns> /// Retrun DB_STATUS /// </returns> public Constants.DB_STATUS Update(Notification notification) { Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN; try { notificationObj = inventory.Notifications.Where(n => n.Id == notification.Id).First(); if (notificationObj != null) { Employee employeeId = inventory.Employees.Where(e => e.Id == notification.Employee.Id).First(); notificationObj.Id = notification.Id; notificationObj.Employee = employeeId; notificationObj.Message = notification.Message; notificationObj.CreatedDate = notification.CreatedDate; inventory.SaveChanges(); status = Constants.DB_STATUS.SUCCESSFULL; } } catch (Exception e) { status = Constants.DB_STATUS.FAILED; } return status; }
/// <summary> /// Insert Notification data to notification table /// </summary> /// <param name="newNotification"></param> /// <returns> /// Returns DB_STATUS /// </returns> public Constants.DB_STATUS Insert(Notification newNotification) { Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN; try { inventory.AddToNotifications(newNotification); inventory.SaveChanges(); status = Constants.DB_STATUS.SUCCESSFULL; } catch (Exception e) { status = Constants.DB_STATUS.FAILED; } return status; }
/// <summary> /// Get the notification data from the Notification table according to the notification parameter /// </summary> /// <param name="notification"></param> /// <returns> /// Notification data /// </returns> public Notification GetNotification(Notification notification) { try { notificationObj = inventory.Notifications.Where(n => n.Id == notification.Id).First(); } catch (Exception e) { notificationObj = null; } return notificationObj; }