コード例 #1
0
        public bool UpdateLoan(string id, int sts)
        {
            LoanRepo repo = new LoanRepo();

            if (IsReturnLate(id))
            {
                StudentBL stuBl = new StudentBL();
                stuBl.UpdatePrice(id);
            }

            if (sts == 3)
            {
                StudentBL stuBl = new StudentBL();
                stuBl.UpdatePriceMissing(id);
            }

            else if (IsResourceMissing(id) || sts == 4)
            {
                StudentBL stuBl = new StudentBL();
                stuBl.UpdatePriceMissing(id);
                sts = 4;
            }

            return(repo.UpdateLoan(id, sts));
        }
コード例 #2
0
        public bool ReturnTransaction(string studentId, int resourceId, DateTime returnDate, int loanStatus)
        {
            //OverDue(loanId,studentId,resourceId,returnDate);
            LoanRepo repo = new LoanRepo();


            return(repo.Return(studentId, resourceId, returnDate, loanStatus));
        }
コード例 #3
0
        private void OverDueIsGreaterThanFive()
        {
            LoanRepo repo = new LoanRepo();

            if (repo.CalculateDate(l.StudentId, l.ResourceId) > 0 && repo.CalculateDate(l.StudentId, l.ResourceId) < 5)
            {
                l.OverDueCharge   += (l.DateReturned - l.DueDate).Days * 5m;
                l.NonReturnCharge += r.PurchasePrice;
            }
        }
コード例 #4
0
        private void OverDueIsZero()
        {
            LoanRepo repo = new LoanRepo();

            if (repo.CalculateDate(l.StudentId, l.ResourceId) < 0)
            {
                l.OverDueCharge   = 0;
                l.NonReturnCharge = 0;
            }
        }
コード例 #5
0
        private bool IsReturnLate(string id)
        {
            LoanRepo repo = new LoanRepo();

            if (repo.CheckIfReturnIsLate(id) > 0)
            {
                Errors.Add(new ValidationError("This student is returning this resource late and will be charged for it"));
                return(true);
            }
            return(false);
        }
コード例 #6
0
        private bool IsResourceUnavailable(string id)
        {
            LoanRepo repo = new LoanRepo();

            if (repo.CheckIfResourceUnavailable(id) > 0)
            {
                Errors.Add(new ValidationError("This resource is no longer in the library."));
                return(true);
            }
            return(false);
        }
コード例 #7
0
        private bool Check_SameType(string studendId, int resourceType)
        {
            LoanRepo repo = new LoanRepo();

            if (repo.Check_SameType(studendId, resourceType) > 0)
            {
                Errors.Add(new ValidationError("This Student has already borrowed same type item in the loan "));
                return(false);
            }

            return(true);
        }
コード例 #8
0
        public bool ResourceTransaction(DateTime checkoutDate, DateTime dueDate)
        {
            LoanRepo repo = new LoanRepo();

            Validation();
            if (Errors.Count == 0)
            {
                return(repo.Transaction(s.StudentId, r.ResourceId, checkoutDate, dueDate));
            }

            return(false);
        }
コード例 #9
0
        private bool IsResourceMissing(string id)
        {
            LoanRepo repo = new LoanRepo();

            if (repo.CheckIfReturnIsMissing(id) > 0)
            {
                Errors.RemoveAt(0);
                Errors.Add(new ValidationError("This resource is missing for 10 days and will be concidered lost, resource price will be charged to student"));
                return(true);
            }
            return(false);
        }
コード例 #10
0
 private bool Check_Reservation()
 {
     if (r.IsReserved == true && (int)r.ResourceStatus == 0)
     {
         LoanRepo repo = new LoanRepo();
         if (s == null || !repo.Check_Reservation(s.StudentId, r.ResourceId))
         {
             Errors.Add(new ValidationError("This is not the student who has reserved this item"));
             return(false);
         }
     }
     return(true);
 }
コード例 #11
0
        CreateLoan(Loan loan, Resource re)
        {
            _lo = loan;

            LoanRepo repo = new LoanRepo();

            Validate(_lo, re);

            if (Errors.Count == 0)
            {
                return(repo.AddLoan(loan));
            }

            return(false);
        }
コード例 #12
0
        public List <Loan> GetLoan(string id = "")
        {
            LoanRepo repo = new LoanRepo();

            return(repo.RetrieveByLoanByStudentId(id));
        }