public object GetBUPACommissionByDate(FilterMapper filterMapper) { try { using (var db = new PERFECTIBSEntities()) { var qry = (from tran in db.tblBankTransactionDetails join cur in db.tblCurrencies on tran.currencyType equals cur.CurrencyID join ag in db.tblAgents on tran.AgentID equals ag.AgentID join cl in db.tblClients on tran.ClientID equals cl.ClientID where tran.IsInvoiceTrf == 0 && tran.PaymentDate >= filterMapper.fromDate && tran.PaymentDate <= filterMapper.toDate group tran by new { cur.CurrencyName, tran.currencyType, ag.AgentCode, tran.PaymentDate, cl.ClientName } into gr select new CommissionDetailMapper { AgentCode = gr.Key.AgentCode, ClientName = gr.Key.ClientName, PaidDate = gr.Key.PaymentDate, CurrencyType = gr.Key.CurrencyName, Amount = gr.Sum(s => s.AgentAmount), CurrencyRate = 0, }).ToList(); return(qry); } } catch (Exception) { throw; } }
public List <AgenCommissionMapper> GetBUPACommissionDetailByDate(FilterMapper filterMapper) { try { using (var db = new PERFECTIBSEntities()) { var qry = (from tran in db.tblBankTransactionDetails join cur in db.tblCurrencies on tran.currencyType equals cur.CurrencyID join ag in db.tblAgents on tran.AgentID equals ag.AgentID join cl in db.tblClients on tran.ClientID equals cl.ClientID where tran.IsInvoiceTrf == 0 && tran.PaymentDate >= filterMapper.fromDate && tran.PaymentDate <= filterMapper.toDate select new AgenCommissionMapper { AgentCode = ag.AgentCode.Trim(), PaymentDate = tran.PaymentDate, Amount = tran.Amount, CurrencyType = cur.CurrencyName, CurrencyRate = 0, }).ToList(); return(qry); } } catch (Exception) { throw; } }
public bool UpdateFilter(ApiFilter filter) { var dalFilter = FilterMapper.ConvertToDALEntity(filter); var id = Update(dalFilter, FilterAdapter); return(true); }
public async Task <OrdersModel> GetUserOrdersAsync(OrdersFilterModel model, long id) { var response = new OrdersModel(); if (id == 0) { response.Errors.Add(ErrorConstants.ModelIsNull); return(response); } var filterModel = FilterMapper.MapOrdersFilteringModel(model); var orders = await _orderRepository.GetByUserIdAsync(filterModel, id); if (orders == null) { response.Errors.Add(ErrorConstants.ImpossibleToFindOrder); return(response); } var responceOrders = new OrdersModel(); foreach (var order in orders.Data) { var orderItemModel = OrderMapper.MapResponseModelToModelItem(order); responceOrders.Items.Add(orderItemModel); } responceOrders.TotalCount = orders.TotalItemsCount; return(responceOrders); }
public IEnumerable <RenewalListMapper> GetClientExpireInfo(FilterMapper filterMapper) { try { using (var db = new PERFECTIBSEntities()) { var qry = (from crh in db.tblClientRequestHeaders join c in db.tblClients on crh.ClientID equals c.ClientID where filterMapper.fromDate <= crh.PolicyEnd && filterMapper.toDate >= crh.PolicyEnd select new RenewalListMapper { ClientId = c.ClientID, ClientName = c.ClientName, ContactNo = c.ContactNo, Address = c.ClientAddress, ExpirationDate = crh.PolicyEnd, }).ToList(); return(qry); } } catch (Exception) { throw; } }
public async Task <PrintingEditionsModel> GetAllAsync(PrintingEditionsFilterModel model) { var response = new PrintingEditionsModel(); if (model == null) { response.Errors.Add(ErrorConstants.ModelIsNull); } var filterModel = FilterMapper.MapPrintingEditionsFilteringModel(model); var printingEditions = await _authorInPrintingEditionsRepository.GetFilteredPrintingEditionsAsync(filterModel); if (printingEditions == null) { response.Errors.Add(ErrorConstants.ImpossibleToFindProduct); return(response); } var products = new PrintingEditionsModel(); foreach (var printingEdition in printingEditions.Data) { var convertedPrice = _currencyConverter.Convert(CurrencyEnum.Currency.USD, model.Currency, printingEdition.PrintingEdition.Price); var printingEditionItemModel = PrintingEditionMapper.MapProductResponseModelToModelItem(printingEdition, model.Currency, convertedPrice); products.Items.Add(printingEditionItemModel); } products.TotalCount = printingEditions.TotalItemsCount; return(products); }
public void WhenSetNullConditionThenSetBothConditionToNull() { var hbmFilter = new HbmFilter(); var mapper = new FilterMapper("MyFilter", hbmFilter); mapper.Condition(null); hbmFilter.condition.Should().Be.Null(); hbmFilter.Text.Should().Be.Null(); }
public void WhenSetSingleLineConditionThenSetSimpleCondition() { var hbmFilter = new HbmFilter(); var mapper = new FilterMapper("MyFilter", hbmFilter); mapper.Condition("aFiled = :aParameter"); hbmFilter.condition.Should().Be("aFiled = :aParameter"); hbmFilter.Text.Should().Be.Null(); }
public void WhenSetMultiLineConditionThenResetSimpleCondition() { var hbmFilter = new HbmFilter(); var mapper = new FilterMapper("MyFilter", hbmFilter); mapper.Condition("aFiled = :aParameter"); mapper.Condition("aFiled = :aParameter" + Environment.NewLine + "AND anotherField = :anotherParam"); hbmFilter.condition.Should().Be.Null(); hbmFilter.Text.Should().Have.SameSequenceAs("aFiled = :aParameter", "AND anotherField = :anotherParam"); }
public void WhenSetSingleLineConditionThenResetTextCondition() { var hbmFilter = new HbmFilter(); var mapper = new FilterMapper("MyFilter", hbmFilter); mapper.Condition("aFiled = :aParameter" + Environment.NewLine + "AND anotherField = :anotherParam"); mapper.Condition("aFiled = :aParameter"); mapper.Condition("aFiled = :aParameter"); hbmFilter.Text.Should().Be.Null(); }
public void WhenSetEmptyConditionThenSetBothConditionToNull() { var hbmFilter = new HbmFilter(); var mapper = new FilterMapper("MyFilter", hbmFilter); mapper.Condition(string.Empty); hbmFilter.condition.Should().Be.Null(); hbmFilter.Text.Should().Be.Null(); mapper.Condition(" "); hbmFilter.condition.Should().Be.Null(); hbmFilter.Text.Should().Be.Null(); }
public AmountMapper GetBupaAmount(FilterMapper map) { try { using (var db = new PERFECTIBSEntities()) { var custCode = (from b in db.tblBussinessUnits where b.BussinessUnit == "BUPA" select new { b.ERPCustomerCode, }).FirstOrDefault(); int[] ids = db.tblBankTransactionDetails.Where(t => t.IsInvoiceTrf == 0).Select(t => t.BankDetailID).ToArray(); var qry = (from tran in db.tblBankTransactionDetails join cur in db.tblCurrencies on tran.currencyType equals cur.CurrencyID where tran.IsInvoiceTrf == 0 && tran.PaymentDate >= map.fromDate && tran.PaymentDate <= map.toDate group tran by new { cur.CurrencyName, tran.currencyType } into gr select new AmountDetailMapper { CurrencyType = gr.Key.CurrencyName, Amount = gr.Sum(s => s.IBSAmount), CurrencyRate = 0, AgentCode = custCode.ERPCustomerCode, }).AsQueryable(); qry = qry.Where(q => q.Amount > 0).AsQueryable(); if (map != null) { if (map.type != null) { if (map.type != "0") { qry = qry.Where(q => q.CurrencyType == map.type).AsQueryable(); } } } AmountMapper mapper = new AmountMapper(); mapper.Ids = ids; mapper.AmountDetailMappers = new List <AmountDetailMapper>(); mapper.AmountDetailMappers.AddRange(qry.ToList()); return(mapper); } } catch (Exception) { throw; } }
public object GetAgentCommission(FilterMapper map) { try { AgenCommissionRootMapper mapper = new AgenCommissionRootMapper(); using (var db = new PERFECTIBSEntities()) { mapper.Ids = db.tblBankTransactionDetails.Where(t => t.IsAgentTrf == 0).Select(t => t.BankDetailID).ToArray(); var qry = (from tran in db.tblBankTransactionDetails join cur in db.tblCurrencies on tran.currencyType equals cur.CurrencyID join ag in db.tblAgents on tran.AgentID equals ag.AgentID where tran.IsAgentTrf == 0 && tran.PaymentDate >= map.fromDate && tran.PaymentDate <= map.toDate // group tran by new { cur.CurrencyName, tran.currencyType, ag.AgentCode } into gr select new AgenCommissionMapper { //CurrencyType = gr.Key.CurrencyName, //Amount = gr.Sum(s => s.AgentAmount), //CurrencyRate = 0, //AgentCode = gr.Key.AgentCode PaymentDate = tran.PaymentDate, CurrencyType = cur.CurrencyName, Amount = tran.AgentAmount, CurrencyRate = 0, AgentCode = ag.AgentCode, }).AsQueryable(); qry = qry.Where(q => q.Amount > 0).AsQueryable(); if (map.type != null) { if (map.type != "0") { qry = qry.Where(q => q.CurrencyType == map.type).AsQueryable(); } } mapper.AgenCommissionMappers = new List <AgenCommissionMapper>(); mapper.AgenCommissionMappers.AddRange(qry.ToList()); return(mapper); } } catch (Exception) { throw; } }
public ApiAdapter(IDataBaseManagerFactory dbEngine, string address, string port, string table, string login, string password) { DbManager = new DatabaseManager(dbEngine, address, port, table, login, password); DbConnector = new DbConnector(DbManager); LanguageAdapter = new LanguageAdapter(DbConnector); UserAdapter = new UserAdapter(DbConnector); UserDetailsAdapter = new UserDetailsAdapter(DbConnector); TransactionTypeAdapter = new TransactionTypeAdapter(DbConnector); TransferTypeAdapter = new TransferTypeAdapter(DbConnector); FrequencyAdapter = new FrequencyAdapter(DbConnector); ImportanceAdapter = new ImportanceAdapter(DbConnector); TagAdapter = new TagAdapter(DbConnector); OperationAdapter = new OperationAdapter(DbConnector); OperationDetailsAdapter = new OperationDetailsAdapter(DbConnector); OperationTagRelationAdapter = new OperationTagAdapter(DbConnector); OperationsGroupAdapter = new OperationsGroupAdapter(DbConnector); OperationsGroupRelationAdapter = new OperationsGroupTagAdapter(DbConnector); FilterAdapter = new FilterAdapter(DbConnector); DashboardAdapter = new DashboardAdapter(DbConnector); DashboardFilterRelationAdapter = new DashboardFilterRelationAdapter(DbConnector); BankAdapter = new BankAdapter(DbConnector); SettingsAdapter = new SettingsAdapter(DbConnector); SchematicTypeAdapter = new SchematicTypeAdapter(DbConnector); SchematicAdapter = new SchematicAdapter(DbConnector); LanguageMapper = new LanguageMapper(); UserMapper = new UserMapper(); UserDetailsMapper = new UserDetailsMapper(); TransactionTypeMapper = new TransactionTypeMapper(); TransferTypeMapper = new TransferTypeMapper(); FrequencyMapper = new FrequencyMapper(); ImportanceMapper = new ImportanceMapper(); TagMapper = new TagMapper(); TagRelationMapper = new RelationTagMapper(); OperationMapper = new OperationMapper(); OperationsGroupMapper = new OperationsGroupMapper(); FilterMapper = new FilterMapper(); DashboardMapper = new DashboardMapper(); DashboardFilterMapper = new DashboardFilterMapper(); BankMapper = new BankMapper(); SettingsMapper = new SettingsMapper(); SchematicTypeMapper = new SchematicTypeMapper(); SchematicMapper = new SchematicMapper(); }
public async Task <AuthorsModel> GetAllAsync(AuthorsFilteringModel model) { var authorModel = new AuthorsModel(); var filterModel = FilterMapper.MapAuthorsFilteringModel(model); var authors = await _authorRepository.GetFilteredAsync(filterModel); if (authors == null || !authors.Data.Any()) { authorModel.Errors.Add(ErrorConstants.ImpossibleToFindAuthor); } foreach (var author in authors.Data) { var resultModel = AuthorMapper.MapResponseModelToModelItem(author); authorModel.Items.Add(resultModel); } authorModel.TotalCount = authors.TotalItemsCount; return(authorModel); }
public async Task <UserModel> GetAllAsync(UsersFilterModel model, long adminId) { var response = new UserModel(); if (model == null) { response.Errors.Add(ErrorConstants.ModelIsNull); return(response); } var filterModel = FilterMapper.MapUserFilteringModel(model); var applicationUsers = await _userRepository.GetFilteredAsync(filterModel, adminId); var users = new UserModel(); foreach (var user in applicationUsers.Data) { var userModelItem = await UpdateStatus(user); users.Items.Add(userModelItem); } users.TotalCount = applicationUsers.TotalItemsCount; return(users); }
public List <ApiFilter> GetFilters(ApiUser user) { FilterMapper.Update(user); return(FilterMapper.ConvertToApiEntitiesCollection(FilterAdapter.GetAll($"user_id={user.Id}")).ToList()); }