Exemplo n.º 1
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));
        }
Exemplo n.º 2
0
 public PlanAccion GetPlan(int id)
 {
     return(_planAccionRepository.Find(id));
 }