public int AddOrUpdate(Department Department) { var Department_ = _DepartmentRepo.GetMany(s => s.DepCode == Department.DepCode).FirstOrDefault(); if (Department_ == null) { _DepartmentRepo.Add(Department); return(unitOfWork.Commit()); } else { Department_.DepCode = Department.DepCode; Department_.DepFloorNumber = Department.DepFloorNumber; Department_.DepManegerID = Department.DepManegerID; Department_.DepName = Department.DepName; Department_.DepPhone = Department.DepPhone; _DepartmentRepo.Update(Department_); return(unitOfWork.Commit()); } }