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 Staff GetStaff(string staffId, IList <Staff> importedStaff) { Staff staff = null; staff = CollectionUtils.SelectFirst <Staff>(importedStaff, delegate(Staff s) { return(s.Id == staffId); }); if (staff == null) { StaffSearchCriteria criteria = new StaffSearchCriteria(); criteria.Id.EqualTo(staffId); IStaffBroker broker = _context.GetBroker <IStaffBroker>(); staff = CollectionUtils.FirstElement(broker.Find(criteria)); } 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); } }