public async Task <List <Transaction> > GetTransactions(int user, int account, int skip = 0, int count = 10) { var result = new List <Transaction>(); var transactions = Context.Transactions.Where(i => i.User.Equals(user) && i.Account.Equals(account)).Skip(skip).Take(count).ToList(); foreach (var i in transactions) { var item = new Transaction(); item.ID = i.ID; item.Account = await Account.GetAccountById(i.Account); item.Category = await Category.GetCategoryById(i.Category); item.SubCategory = await SubCategory.GetSubCategoryById(i.SubCategory); item.Type = await TransactionType.GetTransactionTypeById(i.Type); item.Date = i.Date; item.Description = i.Description; item.Amount = i.Amount; result.Add(item); } return(result); }
public async Task <Transaction> GetTransactionById(int id) { Transaction result = null; var entity = await Context.Transactions.FirstOrDefaultAsync(i => i.ID.Equals(id)); if (entity != null) { result = new Transaction(); result.ID = entity.ID; result.Account = await Account.GetAccountById(entity.Account); result.Category = await Category.GetCategoryById(entity.Category); result.SubCategory = await SubCategory.GetSubCategoryById(entity.SubCategory); result.Type = await TransactionType.GetTransactionTypeById(entity.Type); result.Date = entity.Date; result.Description = entity.Description; result.Amount = entity.Amount; } return(result); }
private void BindSubCategoryById(string subcategoryid) { try { DataTable dt = new DataTable(); dt = local_subcategory.GetSubCategoryById(subcategoryid); if (dt.Rows.Count > 0) { txtSubCategory.Text = Convert.ToString(dt.Rows[0]["SubName"]); ddCategory.SelectedValue = Convert.ToString(dt.Rows[0]["CategoryId"]); ViewState["ID"] = Convert.ToString(dt.Rows[0]["SubCategoryId"]); } } catch { } }