Exemple #1
0
        public NotificacionResponse OperacionNotificacion(NotificacionRequest request)
        {
            var response = new NotificacionResponse()
            {
                EjecucionValida    = false,
                MensajeError       = String.Empty,
                IdUsuarioEjecucion = request.IdUsuarioEjecucion
            };

            try
            {
                request.Item.IdUsuario       = request.IdUsuarioEjecucion;
                request.Item.ListaPaginacion = request.Item.ListaPaginacion.ConfiguracionPaginacionNotificacion();
                response.Item = iNotificacionDominio.OperacionNotificacion(request.Item);
                response.Item.ListaPaginacion.PaginasTotales = (response.Item.ListaPaginacion.TotalRegistros /
                                                                Convert.ToInt16(
                                                                    ConfigurationManager.AppSettings[
                                                                        "paginaRegistrosNotificacion"]) + 1);
                response.EjecucionValida = true;
                return(response);
            }
            catch (Exception ex)
            {
                //TODO: Debe procurar dar un mejor tratamiento a los mensajes de error
                //que serán retornados a la aplicación cliente
                response.MensajeError = ex.Message;
                using (LoggingHelper helper = new LoggingHelper(TipoRepositorio.Xml))
                {
                    helper.Registrar(ex);
                }
            }
            return(null);
        }
        public NotificacionResponse Notificar(NotificacionRequest request)
        {
            Result result = new Result();
            NotificacionResponse response = new NotificacionResponse();

            try
            {
                result = this.NotificarValidacion(request);
                if (result.Satisfactorio == false)
                {
                    throw new Exception(result.Mensaje);
                }

                //(new NotificacionBL()).Notificar(request.NotificacionList);

                response.Result = new Result {
                    Satisfactorio = true
                };
                return(response);
            }
            catch (Exception ex)
            {
                response.Result = new Result {
                    Satisfactorio = false, Mensaje = ex.Message
                };
                return(response);
            }
        }
Exemple #3
0
        public NotificacionResponse OperacionNotificacion(NotificacionRequest request)
        {
            var response = new NotificacionResponse();

            using (var controller = new NotificacionController())
            {
                response = controller.OperacionNotificacion(request);
            }
            return(response);
        }
        private Result NotificarValidacion(NotificacionRequest request)
        {
            try
            {
                //TODOS LOS GUID DEBE DE ESTAR LLENOS PARA IDENTIFICAR LA NOTIFICACION
                request.NotificacionList.ForEach(x =>
                {
                    Guid guidConverted;
                    if (!Guid.TryParse(x.Guid.ToString(), out guidConverted))
                    {
                        throw new Exception("El campo Guid debe de contener datos");
                    }
                });

                //NINGUN GUID DEBE ESTAR REPETIDA
                var result = request.NotificacionList.GroupBy(x => x.Guid)
                             .Select(y => new { y.Key, Count = y.Count() })
                             .Where(z => z.Count > 1).ToList();

                if (result.Any())
                {
                    throw new Exception("El campo Guid no puede estar repetido");
                }

                request.NotificacionList.ForEach(x =>
                {
                    if (string.IsNullOrEmpty(x.De))
                    {
                        throw new Exception("El campo DE debe de contener datos");
                    }

                    if (!x.CuerpoValues.Any())
                    {
                        throw new Exception("El campo CuerpoKeyvalue debe de contener datos");
                    }

                    if (!x.CuerpoValues.Any())
                    {
                        throw new Exception("El campo CuerpoKeyvalue debe de contener datos");
                    }

                    if (!x.Para.Any())
                    {
                        throw new Exception("El campo Para debe de contener datos");
                    }
                    else
                    {
                        x.Para.ForEach(xy =>
                        {
                            if (string.IsNullOrEmpty(xy))
                            {
                                throw new Exception("El campo Para debe de contener datos");
                            }
                        });
                    }
                });

                return(new Result {
                    Satisfactorio = true
                });
            }
            catch (Exception ex)
            {
                return(new Result {
                    Satisfactorio = false, Mensaje = ex.Message
                });
            }
        }