Ejemplo n.º 1
0
        /// <summary>
        /// Sets state of outstanding request to given document
        /// </summary>
        /// <param name="state">State of outstanding request</param>
        /// <param name="documentId">Given document id</param>
        public static void SetOutstanding(bool state, long documentId)
        {
            if (state)
            {
                string title = GetTakableById(documentId).Title;

                string message = title + " is not available now.";
                foreach (Patron p in UsersDataManager.GetQueueToDocument(documentId))
                {
                    NotificationsDataManager.AddNotification(new Notification()
                    {
                        PatronId = p.CardNumber, Message = message
                    });
                }
                message = "You have to return document " + title + ".";
                foreach (Patron p in UsersDataManager.GetPatronsCheckedByDocumentId(documentId))
                {
                    NotificationsDataManager.AddNotification(new Notification()
                    {
                        PatronId = p.CardNumber, Message = message
                    });
                }
            }
            DatabaseHelper.Execute("dbo.spTakable_SetOutstanding @State, @DocumentId", new { State = state, DocumentId = documentId });
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns document in the database
 /// </summary>
 /// <param name="documentId">Id of document that will be returned</param>
 /// <param name="patronId">Id of patron that returns the document</param>
 public static void ReturnDocument(long documentId, long patronId)
 {
     DatabaseHelper.Execute("dbo.spCopies_ReturnDocument @DocumentId, @UserId", new { DocumentId = documentId, UserId = patronId });
     Patron[] patrons = UsersDataManager.GetQueueToDocument(documentId);
     if (patrons.Length != 0)
     {
         Takable takable = GetTakableById(documentId);
         NotificationsDataManager.AddNotification(new Notification()
         {
             PatronId = patrons[0].CardNumber,
             Message  = takable.Title + " now waiting for you."
         });
         DatabaseHelper.Execute("dbo.spQueue_RemovePatronByDocumentId @DocumentId, @PatronId", new { DocumentId = documentId, PatronId = patronId });
     }
 }