Example #1
0
 private void SetUpData()
 {
     _uow.TryExecuteTransaction(() =>
     {
         _uow.Repository <Article>().Add(new Article {
             Name = "Article01", Price = 100.00m
         });
         _uow.Repository <Customer>().Add(new Customer {
             Name = "Customer01"
         });
     });
 }
Example #2
0
        public void CreateOrder(CreateOrderDTO dto)
        {
            _uow.TryExecuteTransaction(() =>
            {
                var articlesFromDb = dto.ArticlesIds.Select(x => _uow.Repository <Article>().DeferredGet(x)).ToList();

                var order = new Order
                {
                    Customer = new Customer {
                        Id = dto.CustomerId
                    },
                    OrderDate = DateTime.UtcNow,
                    Articles  = articlesFromDb
                };

                order.PaymentTransaction = new PaymentTransaction
                {
                    TransactionCost = articlesFromDb.Sum(x => x.Price),
                    Order           = order
                };

                _uow.Repository <Order>().Add(order);
            });
        }
Example #3
0
 /// <summary>
 /// Test insert
 /// </summary>
 /// <param name="test">Test to insert</param>
 public void Add(Test test)
 {
     _unitOfWork.Repository <Test>().Add(test);
     _unitOfWork.SaveChanges();
 }
Example #4
0
 /// <summary>
 /// Course insert
 /// </summary>
 /// <param name="course">Course to insert</param>
 public void Add(Course course)
 {
     _unitOfWork.Repository <Course>().Add(course);
     _unitOfWork.SaveChanges();
 }
 /// <summary>
 /// DepartmentCourse insert
 /// </summary>
 /// <param name="departmentCourse">DepartmentCourse to insert</param>
 public void Add(DepartmentCourse departmentCourse)
 {
     _unitOfWork.Repository <DepartmentCourse>().Add(departmentCourse);
     _unitOfWork.SaveChanges();
 }
 /// <summary>
 /// Department insert
 /// </summary>
 /// <param name="department">Department to insert</param>
 public void Add(Department department)
 {
     _unitOfWork.Repository <Department>().Add(department);
     _unitOfWork.SaveChanges();
 }