Example #1
0
        public async Task <IActionResult> DeleteInsurance(int id)
        {
            var vehicle = await _repo.GetInsurance(id);

            _repo.Delete(vehicle);
            if (await _repo.SaveAll())
            {
                return(Ok());
            }
            return(BadRequest());
        }
Example #2
0
        public async Task <IActionResult> DeleteInsurance(int userId, [FromBody] InsuranceDTO insuranceDTO)
        {
            try
            {
                Insurance insurance = _mapper.Map <Insurance>(insuranceDTO);
                var       results   = await _insuranceRepo.Delete(insurance, userId);

                if (results == false)
                {
                    return(BadRequest(false));
                }
                return(Ok(true));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Example #3
0
        private void tsbDelete_Click(object sender, EventArgs e)
        {
            var userAccess = userAccessRepository.GetAll();

            bool isAllowed = userAccess.Exists(u => u.FullName == Store.ActiveUser &&
                                               u.ObjectName == "Asuransi" && u.IsDelete);

            if (isAllowed == false && Store.IsAdministrator == false)
            {
                MessageBox.Show("Anda tidak dapat menghapus", "Perhatian", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                string employee = insuranceRepository.IsInsuranceUsedByEmployee(new Guid(txtID.Text));

                if (employee != string.Empty)
                {
                    MessageBox.Show("Tidak bisa menghapus " + "\n\n" + txtInsurance.Text + "\n\n" + "dipakai oleh karyawan " + "\n\n" + employee, "Perhatian",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }


                else
                {
                    if (MessageBox.Show("Anda yakin ingin menghapus '" + txtInsurance.Text + "'", "Perhatian",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        insuranceRepository.Delete(new Guid(txtID.Text));
                        LoadInsurance();

                        FillCode();
                    }

                    if (lvwData.Items.Count == 0)
                    {
                        tsbEdit.Enabled   = false;
                        tsbDelete.Enabled = false;
                        ClearForm();
                    }
                }
            }
        }
Example #4
0
 public bool Delete(int id)
 {
     return(repository.Delete(id));
 }
        public bool Delete(int id)
        {
            var result = _insuranceRepository.Delete(id);

            return(result);
        }