public IHttpActionResult FindContacts(ODataQueryOptions <Contact> options, [FromODataUri] ContactFinderModel finder) { return(CommonHelpers.ActionHelper.TryCatchWithLoggerGeneric(() => { ICollection <ContactTableValuedModel> contacts = _unitOfWork.Repository <Contact>().FindContacts(Username, Domain, finder); ICollection <ContactModel> results = _mapperUnitOfWork.Repository <IDomainMapper <ContactTableValuedModel, ContactModel> >().MapCollection(contacts); return Ok(results); }, _logger, LogCategories)); }
public static ICollection <ContactTableValuedModel> FindContacts(this IRepository <Contact> repository, string userName, string domain, ContactFinderModel finderModel) { QueryParameter filterParameter = new QueryParameter(CommonDefinition.SQL_Param_Contact_Filter, DBNull.Value); QueryParameter applyAuthorizationsParameter = new QueryParameter(CommonDefinition.SQL_Param_Contact_ApplyAuthorizations, DBNull.Value); QueryParameter excludeRoleContactsParameter = new QueryParameter(CommonDefinition.SQL_Param_Contact_ExcludeRoleContacts, DBNull.Value); QueryParameter parentIdParameter = new QueryParameter(CommonDefinition.SQL_Param_Contact_ParentId, DBNull.Value); QueryParameter parentToExcludeParameter = new QueryParameter(CommonDefinition.SQL_Param_Contact_ParentToExclude, DBNull.Value); QueryParameter avcpParentIdParameter = new QueryParameter(CommonDefinition.SQL_Param_Contact_AVCPParentId, DBNull.Value); QueryParameter fascicleParentIdParameter = new QueryParameter(CommonDefinition.SQL_Param_Contact_FascicleParentId, DBNull.Value); QueryParameter tenantIdParameter = new QueryParameter(CommonDefinition.SQL_Param_Role_TenantId, DBNull.Value); if (!string.IsNullOrEmpty(finderModel.Filter)) { filterParameter.ParameterValue = finderModel.Filter; } if (finderModel.ApplyAuthorizations.HasValue) { applyAuthorizationsParameter.ParameterValue = finderModel.ApplyAuthorizations.Value; } if (finderModel.ExcludeRoleContacts.HasValue) { excludeRoleContactsParameter.ParameterValue = finderModel.ExcludeRoleContacts.Value; } if (finderModel.ParentId.HasValue) { parentIdParameter.ParameterValue = finderModel.ParentId.Value; } if (finderModel.ParentToExclude.HasValue) { parentToExcludeParameter.ParameterValue = finderModel.ParentToExclude.Value; } if (finderModel.IdTenant.HasValue) { tenantIdParameter.ParameterValue = finderModel.IdTenant.Value; } return(repository.ExecuteModelFunction <ContactTableValuedModel>(CommonDefinition.SQL_FX_Contact_FindContacts, new QueryParameter(CommonDefinition.SQL_Param_Contact_UserName, userName), new QueryParameter(CommonDefinition.SQL_Param_Contact_Domain, domain), filterParameter, applyAuthorizationsParameter, excludeRoleContactsParameter, parentIdParameter, parentToExcludeParameter, avcpParentIdParameter, fascicleParentIdParameter, tenantIdParameter)); }