Beispiel #1
0
        public async Task <OrderDTO> Delete(OrderDTO data)
        {
            var order = await orders.GetAll().FirstOrDefaultAsync(x => x.OrderId == data.OrderId);

            if (order != null)
            {
                order.ProductCount = data.Count;
                order.ProductId    = data.ProductId;
                order.ClientId     = data.ClientId;
                order = await orders.Delete(order);
            }
            return((await GetAsync(data.OrderId)).FirstOrDefault());
        }
Beispiel #2
0
        private async Task <List <OrderDTO> > GetAsync(int orderid)
        {
            //multiple db context in single query. need to fix this issue.
            var query = from order in await orders.GetAll()
                        join product in await products.GetAll() on order.ProductId equals product.ProductId
                        join client in await clients.GetAll() on order.ClientId equals client.ClientId
                        select new OrderDTO
            {
                Client    = client.ClientName,
                Count     = order.ProductCount,
                Product   = product.ProductName,
                Amount    = product.Amount,
                Total     = order.ProductCount * (product.Amount),
                OrderId   = order.OrderId,
                ProductId = product.ProductId,
                ClientId  = client.ClientId
            };

            if (orderid > 0)
            {
                return(query.Where(x => x.OrderId == orderid).ToList());
            }
            else
            {
                return(query.ToList());
            }
        }