private Staff GetStaff(string id, IPersistenceContext context) { Staff staff = null; try { StaffSearchCriteria criteria = new StaffSearchCriteria(); criteria.Id.EqualTo(id); IStaffBroker broker = context.GetBroker <IStaffBroker>(); staff = broker.FindOne(criteria); } catch (EntityNotFoundException) { staff = new Staff(); // need to populate required fields before we can lock (use dummy values) staff.Id = id; staff.Name.FamilyName = ""; staff.Name.GivenName = ""; staff.Sex = Sex.U; context.Lock(staff, DirtyState.New); } return(staff); }
private static Staff FindStaff(string staffId, IPersistenceContext context) { try { if (string.IsNullOrEmpty(staffId)) { return(null); } StaffSearchCriteria criteria = new StaffSearchCriteria(); criteria.Id.EqualTo(staffId); IStaffBroker broker = context.GetBroker <IStaffBroker>(); return(broker.FindOne(criteria)); } catch (EntityNotFoundException) { return(null); } }