public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            tBatch = await _context.tBatch
                     .Include(t => t.client).SingleOrDefaultAsync(m => m.batch_id == id);

            if (tBatch == null)
            {
                return(NotFound());
            }
            else
            {
                tBatch.applicantPrograms = await _context.tApplicantProgram.Where(ap => ap.batch_id == tBatch.batch_id).ToListAsync();

                tBatch.client = await _context.tClient.Where(c => c.client_id == tBatch.client_id).SingleOrDefaultAsync();

                for (int i = 0; i < tBatch.applicantPrograms.Count; i++)
                {
                    tBatch.applicantPrograms[i].applicant = await _context.tApplicant.Where(a => a.applicant_id == tBatch.applicantPrograms[i].applicant_id).SingleOrDefaultAsync();

                    tBatch.applicantPrograms[i].program = await _context.tProgram.Where(p => p.program_id == tBatch.applicantPrograms[i].program_id).SingleOrDefaultAsync();
                }
            }
            return(Page());
        }
Exemple #2
0
        public async Task <IActionResult> OnPostApproveAsync(int ID)
        {
            tBatch batch = await _context.tBatch.SingleOrDefaultAsync(b => b.batch_id == ID);

            _context.Attach(batch).State = EntityState.Modified;
            batch.approval_status        = "Rejected";
            batch.approved_date          = DateTime.Now.ToString("dd MMM yyyy HH:mm");
            batch.approved_by            = "System";
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemple #3
0
        public async Task <IActionResult> PosttBatch([FromBody] tBatch batch)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            batch.approval_status = "Requested";
            batch.create_by       = "System";
            batch.create_date     = DateTime.Now;
            batch.edit_by         = "System";
            batch.edit_date       = DateTime.Now;
            _context.tBatch.Add(batch);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GettBatch", new { id = batch.batch_id }, batch));
        }