public Order PlaceOrder(OrderDto order) { Order newOrder = null; using (var uow = _uowFactory.Create()) { newOrder = new Order(DateTime.Today, order.Total, order.EmployeeNumber); var employee = _employeeRepo.GetByNumber(newOrder.EmployeeNumber); employee.IncrementTotalSales(1); _orderRepo.Save(newOrder); _employeeRepo.Save(employee); uow.Commit(); } return newOrder; }
public IEnumerable<OrderDto> UseDynaicSproc() { //DON"T DO THIS IN THE CONTROLLER, JUST AN EXAMPLE dynamic results =_dynamicDataProvider.ExecuteSproc("OrdersGet", new { Total = 200M }); var response = new Collection<OrderDto>(); if (results != null) { foreach (dynamic result in results) { var orderDto = new OrderDto(); orderDto.EmployeeNumber = result.EmpNum; orderDto.Total = result.Total; response.Add(orderDto); } } return response; }
public IEnumerable<OrderDto> UseDynaicSprocWithArray() { //DON"T DO THIS IN THE CONTROLLER, JUST AN EXAMPLE //dynamic results = _dynamicDataProvider.ExecuteSproc("OrdersGetByIds", new //{ // Ids = new List<int> { 1, 3, 4, 5, 12} //}); var parameters = new Dictionary<string, object>() { {"Ids", new List<int> {1, 3, 4, 5, 12}} }; dynamic results = _dynamicDataProvider.ExecuteSproc("OrdersGetByIds", parameters); var response = new Collection<OrderDto>(); if (results != null) { foreach (dynamic result in results) { var orderDto = new OrderDto(); orderDto.EmployeeNumber = result.EmpNum; orderDto.Total = result.Total; orderDto.Id = result.Id; response.Add(orderDto); } } return response; }