Exemplo n.º 1
0
        public PresupuestoDTO ActualizarPrespuesto(PresupuestoDTO presupuestoDTO)
        {
            using (var unitOfWork = _unitOfWorkFactory.Create())
            {
                Ensure.Argument.NotNull(presupuestoDTO, "presupuesto not null");

                var presupuesto = _presupuestoRepository.Get(presupuestoDTO.Id);
                Ensure.NotNull<NotFoundException>(presupuesto, String.Format("Presupuesto with id {0} not found", presupuestoDTO.Id));

                presupuesto.CambiarImporteNegociado(presupuestoDTO.Importe);

                _presupuestoRepository.Update(presupuesto);
                unitOfWork.Commit();

                return presupuesto.Map<Presupuesto, PresupuestoDTO>();
            }
        }
Exemplo n.º 2
0
        public PresupuestoDTO CrearPresupuesto(PresupuestoDTO presupuestoDTO)
        {
            using (var unitOfWork = _unitOfWorkFactory.Create())
            {
                Ensure.Argument.NotNull(presupuestoDTO, "presupuesto not null");
                Ensure.Argument.NotNull(presupuestoDTO.Cliente, "cliente not null");
                Ensure.Argument.NotNull(presupuestoDTO.Vehiculo, "vehiculo not null");

                var cliente = _clienteRepository.Get(presupuestoDTO.Cliente.Id);
                Ensure.NotNull<NotFoundException>(cliente, String.Format("cliente with id {0} not found", presupuestoDTO.Cliente.Id));
                var vehiculo = _vehiculoRepository.Get(presupuestoDTO.Vehiculo.Id);
                Ensure.NotNull<NotFoundException>(vehiculo, String.Format("vehiculo with id {0} not found", presupuestoDTO.Vehiculo.Id));
                var presupuesto = new Presupuesto(cliente, vehiculo, presupuestoDTO.Importe);

                _presupuestoRepository.Add(presupuesto);
                unitOfWork.Commit();

                return presupuesto.Map<Presupuesto, PresupuestoDTO>();
            }
        }