Example #1
0
        public async Task <(bool IsTrue, string Msg)> ApproveAdmission(Admission admission)
        {
            using (_context)
            {
                using (var transaction = _context.Database.BeginTransaction())
                {
                    _context.Entry(admission).State = EntityState.Modified;
                    StudentLedger studentLedger = new StudentLedger()
                    {
                        Title     = "Account Opened",
                        Debit     = 0,
                        Credit    = 0,
                        Balance   = 0,
                        IP        = admission.IP,
                        Agent     = admission.Agent,
                        Latitude  = admission.Location,
                        Longitude = admission.Location,
                        StudentId = admission.StudentID
                    };
                    _context.StudentLedgers.Add(studentLedger);
                    try
                    {
                        await _context.SaveChangesAsync();

                        var Ledger = await _context.StudentLedgers.Where(x => x.StudentId == admission.StudentID).SingleOrDefaultAsync();

                        if (Ledger == null)
                        {
                            transaction.Rollback();
                            return(false, "Unable To Find Ledger");
                        }
                        else
                        {
                            StudentLedgerTransaction studentLedgerTransaction = new StudentLedgerTransaction()
                            {
                                Title           = "Account Opened",
                                Debit           = 0,
                                Credit          = 0,
                                Balance         = 0,
                                IP              = admission.IP,
                                Agent           = admission.Agent,
                                Latitude        = admission.Location,
                                Longitude       = admission.Location,
                                StudentLedgerId = Ledger.Id
                            };
                            _context.StudentLedgerTransactions.Add(studentLedgerTransaction);
                            await _context.SaveChangesAsync();

                            transaction.Commit();
                            return(true, Result.Success);
                        }
                    }
                    catch (Exception exc)
                    {
                        return(false, Error.GetDetail(exc));
                    }
                }
            }
        }
 public async Task <(bool IsTrue, string ResponseMsg)> Add(StudentLedger studentLedger)
 {
     _context.StudentLedgers.Add(studentLedger);
     try
     {
         return(await _context.SaveChangesAsync() > 0, Result.Success);
     }
     catch (Exception exc)
     {
         return(false, Error.GetDetail(exc));
     }
 }
Example #3
0
 public static bool SameValue(this StudentLedger sl1, StudentLedger sl2)
 {
     return
         (sl1.RecordId == sl2.RecordId &&
          sl1.Source == sl2.Source &&
          sl1.StudentId == sl2.StudentId &&
          sl1.EventId == sl2.EventId &&
          sl1.Week == sl2.Week &&
          sl1.MarkId == sl2.MarkId &&
          sl1.MinsLate == sl2.MinsLate &&
          sl1.Comments == sl2.Comments &&
          sl1.DateChange == sl2.DateChange &&
          sl1.UserId == sl2.UserId);
 }
Example #4
0
        public void Edit(StudentLedger entity)
        {
            StudentLedgerDAL dalObject = new StudentLedgerDAL();

            dalObject.Edit(entity);
        }
Example #5
0
        public void Add(StudentLedger entity)
        {
            StudentLedgerDAL dalObject = new StudentLedgerDAL();

            dalObject.Add(entity);
        }
        private void init()
        {
            #region Insert Test Data of Ledger

            studentLedger = new Dictionary <int, StudentLedger>();

            //StudentNo 1.
            var Ledger = new List <LedgerInfo>();
            // Enter Valid Data
            var ledger1 = new LedgerInfo
            {
                StudentNo   = 1,
                Student     = "Alex",
                TransDate   = new DateTime(10, 02, 05, 09, 15, 00, 000),
                Transaction = "Payment Test 1",
                Debit       = 150.00,
                Credit      = 00.00
            };
            Ledger.Add(ledger1);
            // Enter Valid Data
            var ledger2 = new LedgerInfo
            {
                StudentNo   = 1,
                Student     = "Alex",
                TransDate   = new DateTime(10, 03, 05, 09, 15, 00, 000),
                Transaction = "Payment Test 2",
                Debit       = 350.00,
                Credit      = 00.00
            };
            Ledger.Add(ledger2);
            // Enter Valid Data
            var ledger3 = new LedgerInfo
            {
                StudentNo   = 1,
                Student     = "Alex",
                TransDate   = new DateTime(10, 04, 05, 11, 15, 00, 000),
                Transaction = "Payment Test 3",
                Debit       = 0.00,
                Credit      = 400.00
            };
            Ledger.Add(ledger3);
            // Enter Valid Data
            var ledger4 = new LedgerInfo
            {
                StudentNo   = 1,
                Student     = "Alex",
                TransDate   = new DateTime(10, 06, 03, 09, 35, 00, 000),
                Transaction = "Payment Test 4",
                Debit       = 510.00,
                Credit      = 00.00
            };
            Ledger.Add(ledger4);
            // Enter Valid Data
            var ledger5 = new LedgerInfo
            {
                StudentNo   = 1,
                Student     = "Alex",
                TransDate   = new DateTime(10, 07, 05, 09, 15, 00, 000),
                Transaction = "Payment Test 5",
                Debit       = 0.00,
                Credit      = 200.00
            };
            Ledger.Add(ledger5);
            // Enter Valid Data
            var ledger6 = new LedgerInfo
            {
                StudentNo   = 1,
                Student     = "Alex",
                TransDate   = new DateTime(10, 02, 20, 09, 15, 00, 000),
                Transaction = "Payment Test 6",
                Debit       = 0.00,
                Credit      = 325.00
            };
            Ledger.Add(ledger6);

            var LedgerDetail = new StudentLedger(Ledger);
            studentLedger.Add(1, LedgerDetail);

            //StudentNo 2.
            Ledger = new List <LedgerInfo>();
            for (int i = 0; i < 4; i++)
            {
                // Enter Valid Data
                ledger1 = new LedgerInfo
                {
                    StudentNo   = 2,
                    Student     = "Ben",
                    TransDate   = new DateTime(10, 02, 05, 09, 15, 00, 000),
                    Transaction = "Payment Test " + i,
                    Debit       = 150.00,
                    Credit      = 00.00
                };
                Ledger.Add(ledger1);
            }
            LedgerDetail = new StudentLedger(Ledger);
            studentLedger.Add(2, LedgerDetail);
            #endregion
        }