public void Delete(Guid id) { var entity = _gradeRepository.FindById(id).Result; if (entity.Id == null) { AddError("30000"); } _gradeRepository.Delete(entity); }
public ActionResult Delete(long id) { if (!_academicGradeRepository.Filter(x => x.Grade.Id == id).Any()) { var grade = _gradeRepository.Delete(id); const string title = "Grado ha sido Eliminado"; var content = grade.Name + " ha sido eliminado exitosamente."; _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.SuccessMessage); return(RedirectToAction("Index")); } else { const string title = "Error!"; const string content = "No se puede borrar el grado pues existe un año académico con este grado."; _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.ErrorMessage); return(RedirectToAction("Index")); } }
private void tsbDelete_Click(object sender, EventArgs e) { var userAccess = userAccessRepository.GetAll(); bool isAllowed = userAccess.Exists(u => u.FullName == Store.ActiveUser && u.ObjectName == "Golongan" && u.IsDelete); if (isAllowed == false && Store.IsAdministrator == false) { MessageBox.Show("Anda tidak dapat menghapus", "Perhatian", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { string employee = gradeRepository.IsGradeUsedByEmployee(new Guid(txtID.Text)); if (employee != string.Empty) { MessageBox.Show("Tidak bisa menghapus " + "\n\n" + txtGrade.Text + "\n\n" + "dipakai oleh karyawan " + "\n\n" + employee, "Perhatian", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (MessageBox.Show("Anda yakin ingin menghapus record ini?", "Perhatian", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { gradeRepository.Delete(new Guid(txtID.Text)); LoadGrade(); FillCode(); } if (lvwData.Items.Count == 0) { tsbEdit.Enabled = false; tsbDelete.Enabled = false; ClearForm(); } } } }
public static bool Delete(int GradeId) { return(repository.Delete(GradeId)); }