public async Task <Guid> Handle(CreateTotalAccountCommand request, CancellationToken cancellationToken) { var glId = await _context.MainAccounts.Where(m => m.CustomerId == request.CustomerId && m.Id == request.MainAccountId && m.IsActive).Select(m => m.GeneralLeadgerId).SingleOrDefaultAsync(); if (glId == null) { throw new NotFoundException(nameof(TotalAccount), request.MainAccountId); } var entity = new TotalAccount { TotalAccountIdByCustomer = request.TotalAccountIdByCustomer, TotalAccountNameAr = request.TotalAccountNameAr, TotalAccountNameEn = request.TotalAccountNameEn, CustomerId = request.CustomerId, IsClose = request.IsClose, MainAccountId = request.MainAccountId, GeneralLeadgerId = glId }; _context.TotalAccounts.Add(entity); await _context.SaveChangesAsync(cancellationToken); return(entity.Id); }
public OrderController(IEntityRepository <Order> repository, IEntityRepository <OrderLine> orderLineRepo, IEntityRepository <BasketLine> basketLineRepo, IEntityRepository <Product> productRepo, UserManager <AppUser> userManager, AppIdentityDbContext context, TotalAccount account, Basket basketService) { this.repository = repository; this.orderLineRepo = orderLineRepo; this.basketLineRepo = basketLineRepo; this.productRepo = productRepo; this.userManager = userManager; this.context = context; this.account = account; this.basketService = basketService; }