예제 #1
0
        public async Task <ClientsDto> CreateClient(ClientsDto body)
        {
            var entry = new Clients
            {
                Name = body.Name
            };

            await _context.AddAsync(entry);

            await _context.SaveChangesAsync();

            // Retorno el objeto que ha sido procesado para la creación
            return(_mapper.Map <ClientsDto>(entry));
        }
예제 #2
0
        public async Task <ProductsDto> CreateProduct(ProductsDto body)
        {
            var entry = new Products
            {
                Name        = body.Name,
                Price       = body.Price,
                Description = body.Description
            };

            await _context.AddAsync(entry);

            await _context.SaveChangesAsync();

            return(_mapper.Map <ProductsDto>(entry));
        }
예제 #3
0
        public async Task <OrdersDto> CreateOrder(OrdersDto body)
        {
            var entry = _mapper.Map <Orders>(body);

            // Prepare order detail
            PrepareDetail(entry.ListDetailOrders);

            // Prepare order header
            PrepareHeader(entry);

            await _context.AddAsync(entry);

            await _context.SaveChangesAsync();

            return(_mapper.Map <OrdersDto>(
                       await GetOrderById(entry.IdOrder)
                       ));
        }