public int GenerateDisbursement(DateTime dateRequested, DateTime disbursedDate, string departmentId)
        {
            Department   department   = deptsvc.GetDepartmentById(departmentId);
            Disbursement disbursement = new Disbursement()
            {
                DateRequested      = dateRequested,
                DisbursedDate      = disbursedDate,
                DepartmentId       = department.Id,
                DisbursementStatus = Enums.DisbursementStatus.NOTCOLLECTED
            };

            dbcontext.Add(disbursement);
            dbcontext.SaveChanges();

            dbcontext.Entry(disbursement).GetDatabaseValues();
            return(disbursement.Id);
        }
        public async Task <IActionResult> UpdateDisbursementDetails([FromBody] List <DisbursementDetailAPIModel> ListofdisbursementdetailsAPIModel)
        {
            try
            {
                for (int i = 0; i < ListofdisbursementdetailsAPIModel.Count; i++)
                {
                    DisbursementDetails disbursementdetails = disbursementapiservice.APImodelconvertoDisbursementDetailmodel(ListofdisbursementdetailsAPIModel[i]);

                    _context.Entry(disbursementdetails).State = EntityState.Modified;
                    //use first disbursementdetails to change disbursementdetailapproval
                    if (i == 0)
                    {
                        disbursementapiservice.ChangeDisbursementStatustocollectbyDisbursementDetail(disbursementdetails);
                    }
                }
                await _context.SaveChangesAsync();

                return(NoContent());
            }
            catch (DbUpdateConcurrencyException)
            {
                return(NotFound());
            }
        }