public static OrderHeaderRepository GetOrderHeaderRepository(IUnitOfWork unitOfWork) { var repository = new OrderHeaderRepository(); repository.UnitOfWork = unitOfWork; return(repository); }
public GetOfferHandler(OrderRepository orders, OrderHeaderRepository orderHeaders, CalculatePrices calculatePrices) { _orders = orders; _orderHeaders = orderHeaders; _calculatePrices = calculatePrices; }
public static OrderHeaderRepository GetOrderHeaderRepository() { var repository = new OrderHeaderRepository(); repository.UnitOfWork = GetUnitOfWork(); return(repository); }
public async Task <IActionResult> AddOrder([FromBody] AddOrderDto dto) { if (dto?.ProductList == null) { return(BadRequest("参数不能为空")); } Uow.BeginTransaction(); try { var orderHeader = new OrderHeader { CreateTime = DateTime.UtcNow, CustomerNo = dto.CustomerNo, State = 1, OrderNo = Guid.NewGuid().ToString("N") }; await OrderHeaderRepository.InsertAsync(orderHeader); var orderDetailList = new List <OrderDetail>(); //总消费金额 var totalAmount = 0m; dto.ProductList.ForEach(it => { var orderDetail = new OrderDetail { OrderHeaderId = orderHeader.Id, ProductNo = it.ProductNo, ProductName = it.ProductName, Quantity = it.Quantity, Price = it.Price }; orderDetailList.Add(orderDetail); totalAmount += it.Quantity * it.Price; }); await OrderDetailRepository.BatchInsertAsync(orderDetailList); //更新用户消费金额 var success = await CustomerRepository.UpdateCustomerAmount(dto.CustomerNo, totalAmount); if (!success) { Uow.RollBack(); return(BadRequest()); } } catch (Exception e) { Uow.RollBack(); } Uow.Commit(); return(Ok()); }
public ConfirmOfferHandler(OrderRepository orders, OrderHeaderRepository orderHeaders, CalculatePrices calculatePrices, Clock clock) { _orders = orders; _orderHeaders = orderHeaders; _calculatePrices = calculatePrices; _clock = clock; }
public UnitOfWork(ApplicationDbContext db) { _db = db; Category = new CategoryRepository(_db); FoodType = new FoodTypeRepository(_db); MenuItem = new MenuItemRepository(_db); ApplicationUser = new ApplicationUserRepository(_db); ShoppingCart = new ShoppingCartRepository(_db); OrderHeader = new OrderHeaderRepository(_db); OrderDetails = new OrderDetailsRepository(_db); }
public UnitOfWork(ApplicationDbContext db) { _db = db; Category = new CategoryRepository(_db); Product = new ProductRepository(_db); OrderDetails = new OrderDetailsRepository(_db); OrderHeader = new OrderHeaderRepository(_db); ShoppingCart = new ShoppingCartRepository(_db); ApplicationUser = new ApplicationUserRepository(_db); SP_Call = new SP_Call(_db); }
public UnitOfWork(ApplicationDbContext db) { _db = db; Genre = new GenreRepository(_db); Rating = new RatingRepository(_db); GameObj = new GameRepository(_db); ApplicationUser = new ApplicationUserRepository(_db); ShoppingCart = new ShoppingCartRepository(_db); OrderDetails = new OrderDetailsRepository(_db); OrderHeader = new OrderHeaderRepository(_db); }
public UnitOfWork(ApplicationDbContext db) { _db = db; Category = new CategoryRepository(_db); SubCategory = new SubCategoryRepository(_db); ShoppingCart = new ShoppingCartRepository(_db); AutoPart = new AutoPartRepository(_db); ApplicationUser = new ApplicationUserRepository(_db); Coupon = new CouponRepository(_db); OrderDetails = new OrderDetailsRepository(_db); OrderHeader = new OrderHeaderRepository(_db); }
public UnitOfWork(BulkyBook_DBEntities db) { _db = db; Categories = new CategoryRepository(_db); CoverTypes = new CoverTypeRepository(_db); Products = new ProductRepository(_db); Companies = new CompanyRepository(_db); MyUsers = new MyUserRepository(_db); ShoppingCarts = new ShoppingCartRepository(_db); OrderDetails = new OrderDetailRepository(_db); OrderHeaders = new OrderHeaderRepository(_db); }
public ConfirmOfferHandler(OrderRepository orders, OrderHeaderRepository orderHeaders, CalculatePrices calculatePrices, PriceChangesPolicies priceChangesPolicies, OrderEventsOutbox eventsOutbox, Clock clock) { _orders = orders; _orderHeaders = orderHeaders; _calculatePrices = calculatePrices; _priceChangesPolicies = priceChangesPolicies; _eventsOutbox = eventsOutbox; _clock = clock; }
public UnitOfWork(IorwoodDbContext context) { _context = context; Category = new CategoryRepository(_context); Extra = new ExtraRepository(_context); Unit = new UnitRepository(_context); Product = new ProductRepository(_context); OrderHeader = new OrderHeaderRepository(_context); OrderDetails = new OrderDetailsRepository(_context); StockRepository = new StockRepository(_context); RefundHeader = new RefundHeaderRepository(_context); RefundDetail = new RefundDetailRepository(_context); CurrentMovement = new CurrentMovementRepositroy(_context); AccountingBook = new AccountingBookRepository(_context); UserApplication = new UserApplicationRepository(_context); }
public UnitOfWork(CorpCommDbContext db) { _db = db; Brand = new BrandRepository(_db); StationType = new StationTypeRepository(_db); Unit = new UnitRepository(_db); Department = new DepartmentRepository(_db); Status = new StatusRepository(_db); Size = new SizeRepository(_db); Email = new EmailRepository(_db); Location = new LocationRepository(_db); Event = new EventRepository(_db); Station = new StationRepository(_db); Collateral = new CollateralRepository(_db); OrderDetails = new OrderDetailsRepository(_db); OrderHeader = new OrderHeaderRepository(_db); ShoppingCart = new ShoppingCartRepository(_db); History = new HistoryRepository(_db); SP_Call = new SP_Call(_db); }
public async Task <bool> CancelOrderByCustomerNo(string customerNo) { var count = await OrderHeaderRepository.CancelOrderByCustomerNoAsync(customerNo); return(count > 0); }
public async Task DeleteDatabase() { await OrderHeaderRepository.DeleteAllOrder(); }