public async Task <IActionResult> NextStep(permohonan item) { 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()); item.NextTahapan = service.GetNextTahapan(); service.SetCurrentPermohonan(item); bool success = service.SetNextStep(); return(Ok(success)); } else { throw new SystemException("Anda Tidak Memiliki Akses"); } } catch (Exception ex) { return(BadRequest(ex.Message.ToString())); } }
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 GetItemTahapans_When_Permohonan_IsNull_expected_throwExpt_actual_throwExp() { service.SetCurrentPermohonan(null); Assert.Throws <SystemException>(() => service.ItemsTahapan()); }