예제 #1
0
        public OrderDTO GetById(Guid id)
        {
            using (var context = new OrdersDbContext())
            {
                var entity = context.Orders
                             .Include(o => o.Products)
                             .FirstOrDefault(o => o.Id == id);

                return(EntityMapper.MapOrderToDto(entity));
            }
        }
예제 #2
0
        public Guid Insert(OrderDTO order)
        {
            var entity = EntityMapper.MapOrderFromDto(order);

            entity.Id = Guid.NewGuid();

            using (var context = new OrdersDbContext())
            {
                context.Orders.Add(entity);
                context.SaveChanges();
            }

            return(entity.Id);
        }