Пример #1
0
        public async Task <bool> Read(int rut)
        {
            try
            {
                HttpResponseMessage responseMessage = await client.GetAsync(string.Format("{0}/{1}/{2}", url, "usuario/por-rut", rut));

                if (responseMessage.IsSuccessStatusCode)
                {
                    Colecciones col_web      = new Colecciones();
                    var         responseData = responseMessage.Content.ReadAsStringAsync().Result;
                    Usuario_Web retorno      = JsonConvert.DeserializeObject <Usuario_Web>(responseData);
                    retorno.MantenedoresRutas = col_web.ListaRutasMantenedores().Where(n =>
                                                                                       retorno.Lista_Perfiles.Select(m => m.Id).
                                                                                       Contains(n.IdPerfil)).ToList();

                    MappingThisFromAnother(retorno);
                    return(true);
                }
                return(false);
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
Пример #2
0
        internal bool ValidarCursoViewModel(CursoViewModel curso, bool v)
        {
            Usuario_Web uw = new Usuario_Web();

            _dictionaryError = new Dictionary <string, string>();
            if (string.IsNullOrEmpty(curso.Nombre) || string.IsNullOrWhiteSpace(curso.Nombre))
            {
                _dictionaryError.Add("Nombre", "Este campo es obligatorio.");
            }
            return(_dictionaryError.Count == 0);
        }
Пример #3
0
 public void MappingThisFromAnother(Usuario_Web userFrom)
 {
     this.Rut               = userFrom.Rut;
     this.DigitoV           = userFrom.DigitoV;
     this.Correo            = userFrom.Correo;
     this.Nombre            = userFrom.Nombre;
     this.APaterno          = userFrom.APaterno;
     this.AMaterno          = userFrom.AMaterno;
     this.Password          = userFrom.Password;
     this.Lista_Perfiles    = userFrom.Lista_Perfiles;
     this.MantenedoresRutas = userFrom.MantenedoresRutas;
 }
Пример #4
0
        public async Task <bool> ValidarUsuarioModel(UsuarioViewModel user, bool esCrear)
        {
            Usuario_Web uw = new Usuario_Web();

            _dictionaryError = new Dictionary <string, string>();
            if (user.Rut == 0)
            {
                _dictionaryError.Add("Rut", "Este campo es obligatorio.");
            }
            else if (((bool)await uw.Read(user.Rut) && esCrear) ||
                     (!(bool)await uw.Read(user.Rut) && !esCrear))
            {
                _dictionaryError.Add("Rut", "El Rut existe. Intente con otro Rut nuevamente.");
            }

            if (string.IsNullOrEmpty(user.Correo) || string.IsNullOrWhiteSpace(user.Correo))
            {
                _dictionaryError.Add("Correo", "Este campo es obligatorio.");
            }
            if (string.IsNullOrEmpty(user.Nombre) || string.IsNullOrWhiteSpace(user.Nombre))
            {
                _dictionaryError.Add("Nombre", "Este campo es obligatorio.");
            }
            if (string.IsNullOrEmpty(user.APaterno) || string.IsNullOrWhiteSpace(user.APaterno))
            {
                _dictionaryError.Add("APaterno", "Este campo es obligatorio.");
            }
            if (string.IsNullOrEmpty(user.AMaterno) || string.IsNullOrWhiteSpace(user.AMaterno))
            {
                _dictionaryError.Add("AMaterno", "Este campo es obligatorio.");
            }
            if (!user.PerfilesElegidos.Any())
            {
                _dictionaryError.Add("PerfilesElegidos", "Debe seleccionar al menos un perfil.");
            }
            return(_dictionaryError.Count == 0);
        }