public DepartmentMFC DeleteDepartmentMfc(int id) { DepartmentMFC dbEntry = context.ListDepartments.FirstOrDefault(s => s.Id == id); if (dbEntry != null) { context.ListDepartments.Remove(dbEntry); context.SaveChanges(); } return(dbEntry); }
public void SaveDepartament(DepartmentMFC DepartmentMFC) { if (DepartmentMFC.Id == 0) { context.ListDepartments.Add(DepartmentMFC); } else { DepartmentMFC dbEntry = context.ListDepartments.FirstOrDefault(s => s.Id == DepartmentMFC.Id); if (dbEntry != null) { dbEntry.Name = DepartmentMFC.Name; dbEntry.BranchMFC = DepartmentMFC.BranchMFC; } } context.SaveChanges(); }