예제 #1
0
        public bool Delete(int id)
        {
            Pedido_Itens entity = GetById(id);

            _context.Pedido_Itens.Remove(entity);
            return(_context.SaveChanges() > 0);
        }
예제 #2
0
        public Pedido_Itens Insert(Pedido_Itens entity)
        {
            _context.Pedido_Itens.Add(entity);
            _context.SaveChanges();

            return(entity);
        }
예제 #3
0
        public PedidoItemDTO Insert(PedidoItemDTO item)
        {
            Pedido_Itens entity = _repository.Insert(Mapper.Map <Pedido_Itens>(item));

            item.Id = entity.Id;

            return(item);
        }
예제 #4
0
        public PedidoItemDTO GetById(int id)
        {
            Pedido_Itens entity = _repository.GetById(id);

            if (entity == null)
            {
                throw new Exception("Este Item de Pedido nao existe!");
            }

            return(Mapper.Map <PedidoItemDTO>(entity));
        }
예제 #5
0
        public bool Update(Pedido_Itens entity)
        {
            _context.Entry(entity).State = EntityState.Modified;

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                throw ex;
            }

            return(true);
        }