示例#1
0
        private List <string> canConvertToItemPlanList(List <ItemPlanRequest> items)
        {
            var errors = new List <string>();

            foreach (var item in items)
            {
                errors.AddRange(ItemPlanUtils.CanConvertToItemPlan(item));
            }
            return(errors);
        }
示例#2
0
        private List <ItemPlan> ConvertToItemPlanList(List <ItemPlanRequest> items)
        {
            var itemsPlan = new List <ItemPlan>();

            foreach (var item in items)
            {
                var itemPlan = ItemPlanUtils.ConvertToItemPlan(item);
                itemsPlan.Add(itemPlan);
            }
            return(itemsPlan);
        }
示例#3
0
        public ItemPlanResponse ModificarItem(ItemPlanUpdateRequest request)
        {
            var item = _itemPlanRepository.Find(request.Id);

            if (item == null)
            {
                return(new ItemPlanResponse("No se encontro el item", null));
            }
            var plan = _planAccionRepository.Find(item.PlanAccionId);
            var verificacionPlazoApertura = verificarPlazoAperturaService.Handle(plan.Actividad.Asignador.Identificacion);

            if (verificacionPlazoApertura.Contains("Error"))
            {
                return(new ItemPlanResponse(verificacionPlazoApertura, null));
            }
            var errors = new List <string>();

            errors.AddRange(ItemPlanUtils.CanConvertToItemPlan(request));
            if (errors.Any())
            {
                return(new ItemPlanResponse(StringUtils.ToString(errors), item));
            }
            var auxItem = ItemPlanUtils.ConvertToItemPlan(request);

            errors.AddRange(item.CanDeliver(auxItem.AccionPlaneada, auxItem.AccionRealizada));
            if (errors.Any())
            {
                return(new ItemPlanResponse(StringUtils.ToString(errors), item));
            }
            item.Deliver(auxItem.AccionPlaneada, auxItem.AccionRealizada, item.PlanAccionId);
            var response = "";

            try
            {
                _itemPlanRepository.Update(item);
                response = "Se actualizó el item correctamente";
            }
            catch (Exception e)
            {
                response = "No se pudo actualizar";
            }
            _unitOfWork.Commit();
            return(new ItemPlanResponse(response, item));
        }
示例#4
0
        public ItemPlanResponse RegistrarItem(ItemPlanRequest request)
        {
            var planAccion = _planAccionRepository.Find(request.PlanId);

            if (planAccion == null)
            {
                return(new ItemPlanResponse("No se encontró el plan de acción", null));
            }
            var verificacionPlazoApertura = verificarPlazoAperturaService.Handle(planAccion.Actividad.Asignador.Identificacion);

            if (verificacionPlazoApertura.Contains("Error"))
            {
                return(new ItemPlanResponse(verificacionPlazoApertura, null));
            }

            var errors = ItemPlanUtils.CanConvertToItemPlan(request);

            if (errors.Any())
            {
                var result = String.Join(", ", errors.ToArray());
                return(new ItemPlanResponse(result, null));
            }
            var item     = ItemPlanUtils.ConvertToItemPlan(request);
            var response = "";

            try
            {
                _itemPlanRepository.Add(item);
                response = "Item registrado correctamente";
            }
            catch (Exception e)
            {
                response = "No se pudo registrar";
            }
            _unitOfWork.Commit();
            return(new ItemPlanResponse(response, item));
        }