public async Task <IActionResult> Get(int id)
        {
            try
            {
                var Userid = UserManagers.GetUserId(User);
                var user   = await User.GetPemohon(Userid);

                var service = new PermohonanService(new UOWPermohonan());
                var result  = service.GetPermohonan(id);
                service.Permohonan = result;
                result.Tahapans    = service.ItemsTahapan();
                if (result != null)
                {
                    result.CurrentTahapan = service.GetCurrentTahapan();
                    result.NextTahapan    = service.GetNextTahapan();
                    return(Ok(result));
                }

                else
                {
                    return(NotFound());
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemple #2
0
        public async Task <IActionResult> GetAdminWork()
        {
            try
            {
                var id = UserManager.GetUserId(User);
                if (id == null)
                {
                    throw new SystemException("Anda Belum Login");
                }
                var profile = await User.GetPetugas(id);

                if (profile != null)
                {
                    var service      = new PermohonanService(new UOWPermohonan());
                    var adminService = new AdminService(profile, new PermohonanService(new UOWPermohonan()), new BidangUOW(profile));
                    var list         = new List <permohonan>();
                    foreach (var item in profile.Bidangs)
                    {
                        adminService.SetBidangTugas(item);
                        var result = adminService.GetPermohonans();

                        foreach (var data in result)
                        {
                            service.SetCurrentPermohonan(data);
                            data.CurrentTahapan = service.GetCurrentTahapan();
                            data.NextTahapan    = service.GetNextTahapan();
                            if (data.NextTahapan != null && data.NextTahapan.BidangId == item.Id)
                            {
                                list.Add(data);
                            }
                        }
                    }


                    return(Ok(list));
                }
                else
                {
                    throw new SystemException("Anda Tidak Memiliki Akses");
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message.ToString()));
            }
        }
 public void GetCurrentTahapan_When_CurrentTahapan_Isnull_expected_ThrowSystemExc_actual_throwSystemExc()
 {
     service.SetCurrentPermohonan(new permohonan());
     Assert.Throws <SystemException>(() => service.GetCurrentTahapan());
 }