Ejemplo n.º 1
0
        public async Task Delete(Models.Employees.Employee model, CancellationToken cancellationToken = default)
        {
            var employee = await DbContext.Employees
                           .FirstOrDefaultAsync(x => x.EmployeeId == model.EmployeeId, cancellationToken);

            if (employee != null)
            {
                DbContext.Employees.Remove(employee);
                await DbContext.SaveChangesAsync(cancellationToken);
            }
        }
Ejemplo n.º 2
0
        public async Task <OrderDetails> AddManager(Models.Orders.Order order, Models.Employees.Employee manager, CancellationToken cancellationToken = default)
        {
            var orderDb =
                await DbContext.Orders.FirstOrDefaultAsync(x => x.OrderId == order.OrderId, cancellationToken);

            if (orderDb == null)
            {
                throw new Exception("Order not found");
            }

            var managerDb =
                await DbContext.Employees.FirstOrDefaultAsync(x => x.EmployeeId == manager.EmployeeId, cancellationToken);

            if (managerDb == null)
            {
                throw new Exception("Employee not found");
            }

            orderDb.EmployeeId = managerDb.EmployeeId;
            DbContext.Orders.Update(orderDb);
            await DbContext.SaveChangesAsync(cancellationToken);

            return(await GetDetailModel(orderDb, cancellationToken));
        }
Ejemplo n.º 3
0
 public Task <Models.Employees.Employee> Edit(Models.Employees.Employee model, CancellationToken cancellationToken = default)
 {
     throw new NotSupportedException();
 }