Пример #1
0
        public async Task <object> DeleteBahan(int IdBahan)
        {
            try
            {
                List <Bahan> BahanResponse = await bahanService.GetListByPanduan(IdBahan);

                if (BahanResponse == null || (BahanResponse != null && BahanResponse.Count == 0))
                {
                    throw new NotFoundException("Bahan tidak ditemukan, tidak dapat delete");
                }
                ExecuteResult result = await bahanService.Delete(IdBahan);

                if (result.ReturnVariable <= 0)
                {
                    throw new InternalServerErrorException("An error has occured");
                }
                return(new
                {
                    Status = Models.APIResult.ResultSuccessStatus,
                    ReturnValue = result.ReturnVariable
                });
            }
            catch (NotFoundException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new InternalServerErrorException(e.Message);
            }
        }