public async void AddAssociateOperatingContext(Associate associate, OperatingContext operatingContext) { int operatingContextId = _context.OperatingContexts.ToList().Last().Id; AssociateOperatingContext association = new AssociateOperatingContext(associate.Id, operatingContextId); _context.AssociateOperatingContexts.Add(association); await _context.SaveChangesAsync(); }
public Task <OperatingContextRM> GetOperatingContextForAssociate(int associateId, int operatingContextId) { ValidateAssociateExists(associateId); ValidateOperatingContextExists(operatingContextId); AssociateOperatingContext associateOperatingContext = _context.AssociateOperatingContexts.SingleOrDefault(ae => ae.AssociateId == associateId && ae.OperatingContextId == operatingContextId); if (associateOperatingContext == null) { throw new InvalidOperationException("OperatingContext not found for Associate."); } return(GetOperatingContext(operatingContextId)); }