public IList <WebAPIDto <T> > GetAll() { List <WebAPIDto <T> > items = new List <WebAPIDto <T> >(); ICollection <T> results = null; foreach (IWebAPITenantConfiguration <T, TDao> configuration in _daoConfigurations) { try { WebAPIImpersonatorFacade.ImpersonateDao <TDao, T>(configuration.Dao, (impersonationType, dao) => { results = dao.GetAll(); items.AddRange(results.Select(s => _mapper.TransformDTO(s, configuration.Tenant))); }); } catch (Exception ex) { FileLogger.Error(Logger, string.Format(ERROR_MESSAGE, "GetAll", configuration.Tenant.TenantName), ex); throw new WebAPIException <List <WebAPIDto <T> > >(ex.Message, ex) { Results = items, TenantName = configuration.Tenant.TenantName }; } } return(items); }
public void Update(T entity, string actionType = "") { TDao currentTenant = _daoConfigurations.Single(s => s.IsCurrent).Dao; WebAPIImpersonatorFacade.ImpersonateDao <TDao, T>(currentTenant, (impersonationType, dao) => { dao.Update(ref entity, actionType); }); }
public void Delete(T entity) { TDao currentTenant = _daoConfigurations.Single(s => s.IsCurrent).Dao; WebAPIImpersonatorFacade.ImpersonateDao <TDao, T>(currentTenant, (impersonationType, dao) => { dao.Delete(ref entity); }); }
public WebAPIDto <T> GetById(Guid id) { IWebAPITenantConfiguration <T, TDao> currentTenant = _daoConfigurations.Single(s => s.IsCurrent); return(WebAPIImpersonatorFacade.ImpersonateDao <TDao, T, WebAPIDto <T> >(currentTenant.Dao, (impersonationType, dao) => { return _mapper.TransformDTO(dao.GetById(id), currentTenant.Tenant); })); }
public int Count() { int count = 0; foreach (IWebAPITenantConfiguration <T, TDao> configuration in _daoConfigurations) { try { WebAPIImpersonatorFacade.ImpersonateDao <TDao, T>(configuration.Dao, (impersonationType, dao) => { count += dao.Count(); }); } catch (Exception ex) { FileLogger.Error(Logger, string.Format(ERROR_MESSAGE, "Count", configuration.Tenant.TenantName), ex); throw new WebAPIException <int>(ex.Message, ex) { Results = count }; } } return(count); }