예제 #1
0
        public Task <RegistrarPalmaResponse> Handle(RegistrarPalmaRequest request, CancellationToken cancellationToken)
        {
            var cultivo = _palmAppUnitOfWork.CultivoRepository.Get(new ConsultaCultivoPorIdSpecification(request.CultivoId));

            if (cultivo == null)
            {
                return(Task.FromResult(new RegistrarPalmaResponse("No se ha podido encontrar el Cultivo que contenga ese Lote")));
            }

            var lote = _palmAppUnitOfWork.LoteRepository.Get(new ConsultaLotePorIdSpecification(request.LoteId));

            if (lote == null)
            {
                return(Task.FromResult(new RegistrarPalmaResponse("No se ha podido encontrar el Lote al que intenta agregarle la Palma")));
            }

            var   builder = new Palma.PalmaBuilder();
            Palma palma   = builder.Altura(request.Altura).Descripcion(request.Descripcion).FechaSiembra(request.FechaSiembra).Build();

            lote.AgregarPalma(palma);

            _palmAppUnitOfWork.Commit();

            return(Task.FromResult(new RegistrarPalmaResponse(palma.Id)));
        }
예제 #2
0
        public Task <EditarTareaResponse> Handle(EditarTareaRequest request, CancellationToken cancellationToken)
        {
            var tarea = _palmAppUnitOfWork.TareaRepository.Get(new ConsultaTareaPorIdSpecification(request.TareaId));

            tarea.Editar(request.Nombre, request.Descripcion, request.Estado);
            _palmAppUnitOfWork.Commit();
            return(Task.FromResult(new EditarTareaResponse(tarea.Id)));
        }
예제 #3
0
        public Task <RegistrarTareaResponse> Handle(RegistrarTareaRequest request, CancellationToken cancellationToken)
        {
            var tarea = new Tarea(request.Nombre, request.Descripcion);

            _palmAppUnitOfWork.TareaRepository.Add(tarea);
            _palmAppUnitOfWork.Commit();
            return(Task.FromResult(new RegistrarTareaResponse(tarea.Id)));
        }
예제 #4
0
        public Task <RegistrarCultivoResponse> Handle(RegistrarCultivoRequest request, CancellationToken cancellationToken)
        {
            var cultivo = new Cultivo(request.Nombre, request.FechaSiembra);

            _palmAppUnitOfWork.CultivoRepository.Add(cultivo);
            _palmAppUnitOfWork.Commit();
            return(Task.FromResult(new RegistrarCultivoResponse(cultivo.Id)));
        }
예제 #5
0
        public Task <EditarPalmaResponse> Handle(EditarPalmaRequest request, CancellationToken cancellationToken)
        {
            var Palma = _palmAppUnitOfWork.PalmaRepository.Get(new ConsultaPalmaPorIdSpecification(request.PalmaId));

            Palma.Editar(request.Altura, request.Descripcion, request.FechaSiembra, request.Estado);

            _palmAppUnitOfWork.Commit();

            return(Task.FromResult(new EditarPalmaResponse(Palma.Id)));
        }
예제 #6
0
        public Task <EditarCultivoResponse> Handle(EditarCultivoRequest request, CancellationToken cancellationToken)
        {
            var cultivo = _palmAppUnitOfWork.CultivoRepository.Get(new ConsultaCultivoPorIdSpecification(request.CultivoId));

            cultivo.Editar(request.Nombre, request.FechaSiembra, request.Estado);

            _palmAppUnitOfWork.Commit();

            return(Task.FromResult(new EditarCultivoResponse(cultivo.Id)));
        }
예제 #7
0
        public Task <RegistrarLoteResponse> Handle(RegistrarLoteRequest request, CancellationToken cancellationToken)
        {
            var cultivo = _palmAppUnitOfWork.CultivoRepository.Get(new ConsultaCultivoPorIdSpecification(request.CultivoId));

            if (cultivo == null)
            {
                return(Task.FromResult(new RegistrarLoteResponse("No se ha podido encontrar el Cultivo que contenga ese Lote")));
            }

            var lote = new Lote(cultivo.Id, request.Nombre, request.NumeroHectareas);

            cultivo.AgregarLote(lote);

            _palmAppUnitOfWork.Commit();

            return(Task.FromResult(new RegistrarLoteResponse(lote.Id)));
        }
예제 #8
0
        public Task <EditarLoteResponse> Handle(EditarLoteRequest request, CancellationToken cancellationToken)
        {
            var cultivo = _palmAppUnitOfWork.CultivoRepository.Get(new ConsultaCultivoPorIdSpecification(request.CultivoId));

            if (cultivo == null)
            {
                return(Task.FromResult(new EditarLoteResponse("No se ha podido encontrar el Cultivo que contenga ese Lote")));
            }

            var lote = cultivo.Lotes.FirstOrDefault(t => t.Id == request.LoteId);

            if (lote == null)
            {
                return(Task.FromResult(new EditarLoteResponse("No se ha podido encontrar el Lote que intenta editar")));
            }

            lote.Editar(request.Nombre, request.NumeroHectareas, request.Estado);

            _palmAppUnitOfWork.Commit();

            return(Task.FromResult(new EditarLoteResponse(lote.Id)));
        }