public async Task <List <Bill> > AllForUserAsync(int userId) { return((await Uow.Bills .AllForUserAsync(userId)) .Select(e => BillMapper .MapFromDAL(e)).ToList()); }
public async Task <Bill> GetBillByID(long id) { var param = new DynamicParameters(); param.Add("@ID", id); var mapper = new BillMapper(); return((await SqlMapper.QueryAsync(_unitOfWork.Connection, "GetBillByID", new[] { typeof(Bill), typeof(BillLineItem), typeof(Payment) }, obj => { return mapper.Map(obj[0] as Bill, obj[1] as BillLineItem, obj[2] as Payment); }, param, splitOn: "ID,LineItemID,PaymentID", commandType: CommandType.StoredProcedure, transaction: _unitOfWork.Transaction)).FirstOrDefault()); }
public async Task <List <Bill> > AllForWorkObjectAsync(int workObjectId) { return(await RepositoryDbSet .Include(p => p.Client) .Include(p => p.WorkObject) .Include(p => p.Comment) .ThenInclude(p => p.Translations) .Include(p => p.BillLines) .ThenInclude(p => p.Product) .ThenInclude(p => p.Translations) .Where(p => p.WorkObjectId == workObjectId) .Select(e => BillMapper.MapFromDomain(e)) .ToListAsync()); }
public override async Task <DAL.App.DTO.Bill> FindAsync(params object[] id) { var culture = Thread.CurrentThread.CurrentUICulture.Name.Substring(0, 2).ToLower(); var bill = await RepositoryDbSet.FindAsync(id); if (bill != null) { await RepositoryDbContext.Entry(bill) .Reference(c => c.Client) .LoadAsync(); await RepositoryDbContext.Entry(bill) .Reference(c => c.WorkObject) .LoadAsync(); await RepositoryDbContext.Entry(bill) .Collection(c => c.Payments) // include paymentmethod? .LoadAsync(); await RepositoryDbContext.Entry(bill) .Collection(c => c.BillLines) .LoadAsync(); foreach (var billLine in bill.BillLines) { await RepositoryDbContext.Entry(billLine) .Reference(b => b.Product) .LoadAsync(); await RepositoryDbContext.Entry(billLine.Product) .Collection(b => b.Translations) .Query() .Where(t => t.Culture == culture) .LoadAsync(); } await RepositoryDbContext.Entry(bill) .Reference(c => c.Comment) .LoadAsync(); await RepositoryDbContext.Entry(bill.Comment) .Collection(b => b.Translations) .Query() .Where(t => t.Culture == culture) .LoadAsync(); } return(BillMapper.MapFromDomain(bill)); }
public async Task <Bill> FindForUserAsync(int id, int userId) { var culture = Thread.CurrentThread.CurrentUICulture.Name.Substring(0, 2).ToLower(); return(BillMapper.MapFromDomain( await RepositoryDbSet .Include(p => p.Client) .Include(p => p.WorkObject) //need to include more? .Include(p => p.BillLines) .Include(c => c.Payments) .Include(c => c.Comment) .ThenInclude(t => t.Translations).AsQueryable() .FirstOrDefaultAsync(p => p.Id == id && p.WorkObject.AppUsersOnObject.Any(q => q.AppUserId == userId)))); }
public async Task <List <BillLine> > AllForBillAsync(int?billId) { return((await Uow.BillLines .AllForBillAsync(billId)) .Select(c => new BillLine() { Id = c.Id, BillId = c.BillId, Bill = BillMapper.MapFromDAL(c.Bill), Product = c.Product, Amount = c.Amount, Sum = c.Sum, DiscountPercent = c.DiscountPercent, SumWithDiscount = c.Sum * c.Amount * (1 - c.DiscountPercent / 100) }) .ToList()); }
public override async Task <List <DAL.App.DTO.Bill> > AllAsync() { return(await RepositoryDbSet .Include(p => p.Client) .Include(p => p.WorkObject) .Include(p => p.Comment) .ThenInclude(p => p.Translations) .Include(p => p.BillLines) .ThenInclude(p => p.Product) .ThenInclude(p => p.Translations) .Include(p => p.Payments) .ThenInclude(p => p.PaymentMethod) .ThenInclude(p => p.PaymentMethodValue) .ThenInclude(p => p.Translations) .Select(e => BillMapper.MapFromDomain(e)) .ToListAsync()); }
public async Task <List <Bill> > AllForUserAsync(int userId) { var culture = Thread.CurrentThread.CurrentUICulture.Name.Substring(0, 2).ToLower(); var resultList = await RepositoryDbSet .Include(c => c.Client) .Include(c => c.WorkObject) .ThenInclude(c => c.AppUsersOnObject) .ThenInclude(c => c.AppUser) .Include(c => c.BillLines) .Include(c => c.Comment) .ThenInclude(t => t.Translations) .Where(p => p.WorkObject.AppUsersOnObject.Any(q => q.AppUserId == userId)) .Select(c => BillMapper.MapFromDomain(c)) .ToListAsync(); // .Select(c => new // { // Id = c.Id, //// Client = ClientMapper.MapFromDomain(c.Client), // ClientId = c.ClientId, // ArrivalFee = c.ArrivalFee, // SumWithoutTaxes = c.SumWithOutTaxes, // TaxPercent = c.TaxPercent, // DateTime = c.DateTime, // InvoiceNr = c.InvoiceNr, // Comment = c.Comment, // Translations = c.Comment.Translations // }) // .ToListAsync(); // // var resultList = res.Select(c => new Bill() // { // Id = c.Id, //// Client = c.Client, // ClientId = c.ClientId, // ArrivalFee = c.ArrivalFee, // SumWithoutTaxes = c.SumWithoutTaxes, // TaxPercent = c.TaxPercent, // DateTime = c.DateTime, // InvoiceNr = c.InvoiceNr, // Comment = c.Comment.Translate() // // }).ToList(); return(resultList); }
public override async Task <Bill> FindAsync(params object[] id) { var bill = await Uow.Bills.FindAsync(id); if (bill != null) { var billLines = await Uow.BillLines.AllForBillAsync(bill.Id); bill.SumWithoutTaxes = bill.ArrivalFee; foreach (var billLine in billLines) { bill.SumWithoutTaxes += billLine.SumWithDiscount; } bill.FinalSum = bill.SumWithoutTaxes * 100 / (100 - bill.TaxPercent); } return(BillMapper.MapFromDAL(bill)); // return BillMapper.MapFromDAL(await Uow.Bills.FindAsync(id)); }
public async Task <IList <Bill> > Query(BillFilter filter) { var param = new DynamicParameters(); param.Add("ID", filter.ID); param.Add("RequestID", filter.RequestID); param.Add("RefNo", filter.RefNo); param.Add("RefID", filter.RefID); param.Add("CustomerName", filter.CustomerName); param.Add("Status", filter.Status); param.Add("From", filter.From); param.Add("To", filter.To); param.Add("InvoiceNo", filter.InvoiceNo); param.Add("Type", filter.Type); var mapper = new BillMapper(); return((await SqlMapper.QueryAsync(_unitOfWork.Connection, "SelectBill", new[] { typeof(Bill), typeof(BillLineItem), typeof(Payment) }, obj => { return mapper.Map(obj[0] as Bill, obj[1] as BillLineItem, obj[2] as Payment); }, param, splitOn: "ID,LineItemID,PaymentID", commandType: CommandType.StoredProcedure, transaction: _unitOfWork.Transaction)).Distinct().ToList()); }
public async Task <IEnumerable <Bill> > GetUserBills(Guid userId) { return((await RepoDbSet.AsQueryable().Where(b => b.AppUserId.Equals(userId)).ToListAsync()).Select(domainBill => BillMapper.Map(domainBill))); }
public Bill AddNewBill(DAL.App.DTO.Bill bill) { var domain = RepoDbSet.AddAsync(BillMapper.MapToDomain(bill)).Result.Entity; return(BillMapper.Map((domain))); }
public async Task <Bill> FindForUserAsync(int id, int userId) { return(BillMapper.MapFromDAL(await Uow.Bills.FindForUserAsync(id, userId))); }