Ejemplo n.º 1
0
        /// <summary>
        /// Book is Assigned to the Borrower
        /// </summary>
        /// <param> AssignBookModel</param>
        ///   <returns>bool<BorrowersModel> </returns>
        public bool Post_AssignBook(AssignBookModel aBookModel)
        {
            AssignBookModel aBook = new AssignBookModel();

            aBookModel.AssignedDate = DateTime.Now;            //Current Assign Date
            aBookModel.DueDate      = DateTime.Now.AddDays(7); //7 Days time to return book
            return(aBook.AssignBook(aBookModel));
        }
Ejemplo n.º 2
0
        ///<summary>
        /// DeAssign the Book incase user has retruned it
        ///</summary>
        ///<param> BookId</param>
        ///<param> BorrowerId</param>
        ///<returns>bool<BorrowersModel> </returns>
        public bool GetDeAssignBook(int BookId, int BorrowerId)
        {
            AssignBookModel aBook = new AssignBookModel();

            aBook.BorrowerID = BorrowerId;
            aBook.BookID     = BookId;

            return(aBook.DeAssignBook(aBook));
        }
Ejemplo n.º 3
0
        ///<summary>
        ///All Issued books History
        ///</summary>
        ///<param> jQueryDataTableParamModel</param>
        ///<param> searchCriteria</param>
        ///<returns>bool<BorrowersModel> </returns>
        public JqDataTable <object[]> Post_AllAssignedBooks(jQueryDataTableParamModel param, string searchCriteria, string type)
        {
            try
            {
                SearchCriteria criteria = ConvertFromJsonToObject <SearchCriteria>(searchCriteria);

                int startIndex = 0;
                if (param.iDisplayStart > 0)
                {
                    startIndex = param.iDisplayStart + 1;
                }
                else
                {
                    startIndex = param.iDisplayStart;
                }

                criteria.StartIndex = startIndex;
                criteria.EndIndex   = param.iDisplayStart + param.iDisplayLength;
                criteria.SortOrder  = param.sSortDir_0;
                criteria.SortingCol = param.iSortCol_0;

                if (String.IsNullOrWhiteSpace(criteria.Text))
                {
                    criteria.Text = String.Empty;
                }

                AssignBookModel obj   = new AssignBookModel();
                int             count = obj.TotalAssigned(criteria);

                var data = new List <object[]>();

                IList <AssignBookModel> bModel = new List <AssignBookModel>();
                bModel = obj.GetAllAssignedBooks(criteria);


                foreach (AssignBookModel item in bModel)
                {
                    var array = new object[8];
                    array[0] = item.Title;
                    array[1] = item.FirstName + "," + item.LastName;
                    array[2] = Convert.ToDateTime(item.AssignedDate).ToString("MMMM d, yyyy");
                    array[3] = Convert.ToDateTime(item.DueDate).ToString("MMMM d, yyyy");;
                    array[4] = (item.isCurrentlyAssigned == true) ? "N" : "Y";
                    array[5] = (DateTime.Now - item.DueDate).TotalDays > 0 && item.isCurrentlyAssigned == true ? "Y" : "N";
                    array[6] = item.BorrowerID;
                    array[7] = item.BookID;

                    data.Add(array);
                }

                return(new JqDataTable <object[]>
                {
                    sEcho = param.sEcho,
                    iTotalRecords = count,
                    iTotalDisplayRecords = count,
                    aaData = data
                });
            }

            catch (Exception e)
            {
                return(null);
            }
        }