Ejemplo n.º 1
0
        public static IQueryable <Deposit> GetDeposits(this HSBorsDb db, long?unit_cost_id = null, long?account_id = null, EntityStatus?status = null, long?id = null, long?fund_id = null)
        {
            var query = db.Deposits.AsQueryable();

            if (unit_cost_id.HasValue)
            {
                query = query.Where(item => item.unit_cost_id == unit_cost_id);
            }
            if (account_id.HasValue)
            {
                query = query.Where(item => item.account_id == account_id);
            }
            if (status.HasValue)
            {
                query = query.Where(item => item.status == status);
            }
            if (id.HasValue)
            {
                query = query.Where(item => item.id == id);
            }
            if (fund_id.HasValue)
            {
                query = query.Where(item => item.account.fund_id == fund_id);
            }
            return(query.OrderByDescending(x => x.date));
        }
Ejemplo n.º 2
0
        public static IQueryable <Account> GetAccounts(this HSBorsDb db, SearchAccountRequest request)
        {
            EntityStatus?status = null;

            if (!string.IsNullOrWhiteSpace(request.status))
            {
                status = EnumConvert.StringToEnum <EntityStatus>(request.status);
            }
            return(GetAccounts(db, request.id, request.fund_id, status));
        }
Ejemplo n.º 3
0
        public async static Task <bool> Edit(this Purchase entity, HSBorsDb db, SingleResponse <object> response)
        {
            var existingEntity = await db.GetPurchase(entity);

            if (existingEntity == null)
            {
                response.ErrorCode = (int)ErrorHandler.ErrorCode.NoContent;
                return(false);
            }

            existingEntity.UpdateProperty(entity);

            return(true);
        }
Ejemplo n.º 4
0
        public static IQueryable <User> GetUsers(this HSBorsDb db, long?id = null, int?status = null)
        {
            var query = db.Users.AsQueryable();

            if (id.HasValue)
            {
                query = query.Where(item => item.id == id);
            }
            if (status.HasValue)
            {
                query = query.Where(item => item.status == (EntityStatus)status);
            }

            return(query);
        }
Ejemplo n.º 5
0
        public static IQueryable <UnitCost> GetUnitcosts(this HSBorsDb db, long?id = null, long?fund_id = null)
        {
            var query = db.UnitCosts.AsQueryable();

            if (id.HasValue)
            {
                query = query.Where(item => item.id == id);
            }
            if (fund_id.HasValue)
            {
                query = query.Where(item => item.fund_id == fund_id);
            }

            return(query.OrderByDescending(x => x.date));
        }
Ejemplo n.º 6
0
        public static IQueryable <Setting> GetSettings(this HSBorsDb db, long?id = null, SettingType?type = null)
        {
            var query = db.Settings.AsQueryable();

            if (id.HasValue)
            {
                query = query.Where(item => item.id == id);
            }
            if (type.HasValue)
            {
                query = query.Where(item => item.type == type);
            }

            return(query);
        }
Ejemplo n.º 7
0
        public static IQueryable <Fund> GetFunds(this HSBorsDb db, long?id = null, long?account_id = null, EntityStatus?status = null)
        {
            var query = db.Funds.AsQueryable();

            if (id.HasValue)
            {
                query = query.Where(item => item.id == id);
            }
            if (status.HasValue)
            {
                query = query.Where(item => item.status == status);
            }

            return(query);
        }
Ejemplo n.º 8
0
        public static IQueryable <Purchase> GetPurchases(this HSBorsDb db, long?id = null, long?deposit_id = null, int?status = null)
        {
            var query = db.Purchases.AsQueryable();

            if (id.HasValue)
            {
                query = query.Where(item => item.id == id);
            }
            if (deposit_id.HasValue)
            {
                query = query.Where(item => item.deposit_id == deposit_id);
            }

            return(query);
        }
Ejemplo n.º 9
0
        public async static Task <bool> Edit(this Purchase purchase, HSBorsDb db, AddPurchaseRequest request, SingleResponse <object> response)
        {
            if (!request.CheckValidation(response))
            {
                return(false);
            }
            var entity         = request.ToEntity(true);
            var existingEntity = await db.GetPurchase(entity);

            if (existingEntity == null)
            {
                response.ErrorCode = (int)ErrorHandler.ErrorCode.NoContent;
                return(false);
            }

            existingEntity.UpdateProperty(request.ToEntity());

            return(true);
        }
Ejemplo n.º 10
0
        public async static Task <IEnumerable <object> > GetPurchaseList(this HSBorsDb db, PagedResponse <object> response, SearchPurchaseRequest request)
        {
            var query = await GetPurchases(db, request).Paging(response, request.page_start, request.page_size)
                        .Include(x => x.bank_copartner).Include(x => x.buyer)
                        .ToListAsync();

            var entity_list = query
                              .Select(x => new
            {
                x.id,
                x.amount,
                x.bank_copartner_id,
                x.bank_copartner_name,
                x.bank_copartner_intrest,
                x.bank_copartner_percent,
                x.buyer_id,
                x.buyer_name
            });

            return(entity_list);
        }
Ejemplo n.º 11
0
 public static IQueryable <Fund> GetFunds(this HSBorsDb db, SearchFundRequest request)
 {
     return(GetFunds(db, request.id, request.account_id, (EntityStatus?)request.status));
 }
Ejemplo n.º 12
0
 public static async Task <Deposit> GetDeposit(this HSBorsDb db, Deposit entity)
 => await db.Deposits.FirstOrDefaultAsync(item => item.id == entity.id);
Ejemplo n.º 13
0
 public static IQueryable <Deposit> GetDeposits(this HSBorsDb db, SearchDepositRequest request)
 {
     return(GetDeposits(db, request.unit_cost_id, request.account_id, (EntityStatus?)request.status, null, request.fund_id));
 }
Ejemplo n.º 14
0
 public AccountController(IDistributedCache distributedCache, ILogger <AccountController> logger, HSBorsDb dbContext) :
     base(distributedCache, logger, dbContext)
 {
 }
Ejemplo n.º 15
0
 public static async Task <Account> GetAccount(this HSBorsDb db, Account entity)
 => await db.Accounts.FirstOrDefaultAsync(item => item.id == entity.id || (item.fund_id == entity.fund_id && item.name == entity.name));
Ejemplo n.º 16
0
 public SettingController(IDistributedCache distributedCache, ILogger <SettingController> logger, HSBorsDb dbContext) :
     base(distributedCache, logger, dbContext)
 {
 }
Ejemplo n.º 17
0
 public DepositController(IDistributedCache distributedCache, ILogger <DepositController> logger, HSBorsDb dbContext) :
     base(distributedCache, logger, dbContext)
 {
 }
Ejemplo n.º 18
0
 public static IQueryable <UnitCost> GetUnitcosts(this HSBorsDb db, SearchUnitRequest request)
 {
     return(GetUnitcosts(db, request.id, request.fund_id));
 }
Ejemplo n.º 19
0
 public static IQueryable <Purchase> GetPurchases(this HSBorsDb db, SearchPurchaseRequest request)
 {
     return(GetPurchases(db, request.id, request.deposit_id, request.status));
 }
Ejemplo n.º 20
0
 public static async Task <User> GetUser(this HSBorsDb db, User entity)
 => await db.Users.FirstOrDefaultAsync(item => item.id == entity.id);
Ejemplo n.º 21
0
 public static async Task <Fund> GetFund(this HSBorsDb db, Fund entity)
 => await db.Funds.FirstOrDefaultAsync(item => (item.name == entity.name) || item.id == entity.id);
Ejemplo n.º 22
0
 public static async Task <Setting> GetSetting(this HSBorsDb db, Setting entity)
 => await db.Settings.FirstOrDefaultAsync(item => item.id == entity.id);
Ejemplo n.º 23
0
 public static IQueryable <User> GetUsers(this HSBorsDb db, SearchUserRequest request)
 {
     return(GetUsers(db, request.id, request.status));
 }
Ejemplo n.º 24
0
 public static async Task <UnitCost> GetUnitcost(this HSBorsDb db, UnitCost entity)
 => await db.UnitCosts.FirstOrDefaultAsync(item => (item.date == entity.date && item.fund_id == entity.fund_id) || item.id == entity.id);
Ejemplo n.º 25
0
 public static async Task <Purchase> GetPurchase(this HSBorsDb db, Purchase entity)
 => await db.Purchases.FirstOrDefaultAsync(item => item.id == entity.id);
Ejemplo n.º 26
0
 public DefaultController(IDistributedCache distributedCache, ILogger <DefaultController> logger, HSBorsDb dbContext)
 {
     _distributedCache = distributedCache;
     Logger            = logger;
     DbContext         = dbContext;
 }
Ejemplo n.º 27
0
 public PurchaseController(IDistributedCache distributedCache, ILogger <PurchaseController> logger, HSBorsDb dbContext) :
     base(distributedCache, logger, dbContext)
 {
 }