public async Task ClosePaidOrders(string employeeEmail)
        {
            List <OrderWithFullDependencyDto> unclosedOrders = new List <OrderWithFullDependencyDto>();
            int companyId = await GetCompanyId(employeeEmail);

            using (UnitOfWorkProvider.Create())
            {
                unclosedOrders = await _orderService.GetUnclosedOrdersOfCompany(companyId);
            }

            foreach (OrderWithFullDependencyDto o in unclosedOrders)
            {
                if (o.Items.TrueForAll(i => i.IsPaid))
                {
                    o.IsClosed = true;
                    using (UnitOfWorkProvider.Create())
                    {
                        await _orderService.Update(new OrderDto
                        {
                            CompanyId      = o.CompanyId,
                            Id             = o.Id,
                            IsClosed       = true,
                            OrderStartTime = o.OrderStartTime,
                            OrderTable     = o.OrderTable
                        });

                        await UnitOfWorkProvider.GetUnitOfWorkInstance().Commit();
                    }
                }
            }
        }
 public async Task Delete(int orderItemId)
 {
     using (UnitOfWorkProvider.Create())
     {
         _OrderItemService.DeleteProduct(orderItemId);
         await UnitOfWorkProvider.GetUnitOfWorkInstance().Commit();
     }
 }
 public async Task Create(OrderItemDto orderItem)
 {
     using (UnitOfWorkProvider.Create())
     {
         _OrderItemService.Create(orderItem);
         await UnitOfWorkProvider.GetUnitOfWorkInstance().Commit();
     }
 }
Exemple #4
0
 public async Task Delete(OrderDto order)
 {
     using (UnitOfWorkProvider.Create())
     {
         _orderService.DeleteProduct(order.Id);
         await UnitOfWorkProvider.GetUnitOfWorkInstance().Commit();
     }
 }
 public async Task Delete(int employeeId)
 {
     using (UnitOfWorkProvider.Create())
     {
         _companyService.DeleteProduct(employeeId);
         await UnitOfWorkProvider.GetUnitOfWorkInstance().Commit();
     }
 }
Exemple #6
0
 public async Task Delete(int paymentId)
 {
     using (UnitOfWorkProvider.Create())
     {
         _paymentService.DeleteProduct(paymentId);
         await UnitOfWorkProvider.GetUnitOfWorkInstance().Commit();
     }
 }
 public async Task Create(CompanyDto employee)
 {
     using (UnitOfWorkProvider.Create())
     {
         _companyService.Create(employee);
         await UnitOfWorkProvider.GetUnitOfWorkInstance().Commit();
     }
 }
Exemple #8
0
 public async Task Create(PaymentDto payment)
 {
     using (UnitOfWorkProvider.Create())
     {
         _paymentService.Create(payment);
         await UnitOfWorkProvider.GetUnitOfWorkInstance().Commit();
     }
 }
Exemple #9
0
 public async Task Delete(MenuItemDto menuItem)
 {
     using (UnitOfWorkProvider.Create())
     {
         _menuItemService.DeleteProduct(menuItem.Id);
         await UnitOfWorkProvider.GetUnitOfWorkInstance().Commit();
     }
 }
 public async Task Delete(EmployeeDto employee)
 {
     using (UnitOfWorkProvider.Create())
     {
         _employeeService.DeleteProduct(employee.Id);
         await UnitOfWorkProvider.GetUnitOfWorkInstance().Commit();
     }
 }
Exemple #11
0
        public async Task Update(OrderDto order)
        {
            using (UnitOfWorkProvider.Create())
            {
                await _orderService.Update(order);

                await UnitOfWorkProvider.GetUnitOfWorkInstance().Commit();
            }
        }
Exemple #12
0
        public async Task Update(MenuItemDto menuItem)
        {
            using (UnitOfWorkProvider.Create())
            {
                await _menuItemService.Update(menuItem);

                await UnitOfWorkProvider.GetUnitOfWorkInstance().Commit();
            }
        }
        public async Task Update(EmployeeDto employee)
        {
            using (UnitOfWorkProvider.Create())
            {
                await _employeeService.Update(employee);

                await UnitOfWorkProvider.GetUnitOfWorkInstance().Commit();
            }
        }
        public async Task Update(CompanyUpdateNameDto company)
        {
            using (UnitOfWorkProvider.Create())
            {
                var dbCompany = await _companyService.GetAsync(company.Id);

                dbCompany.Name = company.Name;
                await _companyService.Update(dbCompany);

                await UnitOfWorkProvider.GetUnitOfWorkInstance().Commit();
            }
        }
        public async Task CreateNewOrderForCompany(string employeeEmail, OrderDto order)
        {
            using (UnitOfWorkProvider.Create())
            {
                int companyId = (await _employeeService.GetEmployeeByEmail(employeeEmail)).CompanyId;
                if (companyId == 0)
                {
                    throw new ArgumentException("Unable to create new order for company with employee having email " + employeeEmail + ". No company found");
                }

                order.CompanyId = companyId;
                _orderService.Create(order);
                await UnitOfWorkProvider.GetUnitOfWorkInstance().Commit();
            }
        }
        public async Task RegisterEmployee(EmployeeDto employee, string employeeEmail)
        {
            using (UnitOfWorkProvider.Create())
            {
                int companyId = (await _employeeService.GetEmployeeByEmail(employeeEmail)).CompanyId;
                if (companyId == 0)
                {
                    throw new ArgumentException("Unable to create new order for company with employee having email " + employeeEmail + ". No company found");
                }

                employee.CompanyId = companyId;
                await _employeeService.RegisterEmployeeAsync(employee);

                await UnitOfWorkProvider.GetUnitOfWorkInstance().Commit();
            }
        }