예제 #1
0
        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> 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));
            }
        }
예제 #3
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 GetNextTahapanWhen_CurrentTahapan_IsNull_expected_Throw_Actual_throw()
 {
     Assert.Throws <SystemException>(() => service.GetNextTahapan());
 }