public async Task <IActionResult> Edit(int id, [Bind("IdParkir,Status")] Persetujuan persetujuan)
        {
            if (id != persetujuan.IdParkir)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(persetujuan);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PersetujuanExists(persetujuan.IdParkir))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdParkir"] = new SelectList(_context.KendaraanMasukk, "IdParkir", "JenisKendaraan", persetujuan.IdParkir);
            return(View(persetujuan));
        }
        public async Task <KIM> CreateNewKIM(int itempengajuanid, KIM kim)
        {
            try
            {
                var pengajuanItem = _context.PengajuanItems.Where(xx => xx.Id == itempengajuanid)
                                    .Include(x => x.Truck).FirstOrDefault();
                var tracker = _context.ChangeTracker.Entries();
                var truck   = _context.Trucks.Where(xx => xx.Id == pengajuanItem.Truck.Id).Include(xx => xx.Kims).FirstOrDefault();
                _context.ChangeTracker.Clear();
                _context.Attach(truck);
                truck.Kims.Add(kim);
                var persetujuan = new Persetujuan {
                    User = _userLogin, StatusPersetujuan = Helpers.StatusPersetujuan.Complete, ApprovedBy = Helpers.UserType.Administrator, ApprovedDate = DateTime.Now
                };
                _context.Entry(persetujuan.User).State = EntityState.Unchanged;
                _context.Attach(pengajuanItem);
                pengajuanItem.Persetujuans.Add(persetujuan);
                var result = await _context.SaveChangesAsync();

                return(kim);
            }
            catch (System.Exception ex)
            {
                throw new SystemException(ex.Message);
            }
        }
        public async Task <IActionResult> Create([Bind("IdParkir,Status")] Persetujuan persetujuan)
        {
            if (ModelState.IsValid)
            {
                _context.Add(persetujuan);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdParkir"] = new SelectList(_context.KendaraanMasukk, "IdParkir", "JenisKendaraan", persetujuan.IdParkir);
            return(View(persetujuan));
        }