Exemple #1
0
        public async Task <IActionResult> ComenzarRecuperacion(CorreoViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var usuario = await _context.Usuarios
                          .FirstOrDefaultAsync(u => u.Correo == model.Correo);

            if (usuario != null)
            {
                RecuperaContrasenia recupera = new RecuperaContrasenia();
                recupera.IdUsuario     = usuario.IdUsuario;
                recupera.Token         = GenerarToken();
                recupera.FechaModifica = DateTime.Now;
                recupera.IpModifica    = Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString();
                _context.Add(recupera);
                await _context.SaveChangesAsync();

                // Enviamos correo
                UtilsMethods.EnviarCorreo(usuario, recupera.Token);
                ViewBag.Message = "Se ha enviado un correo con un link de recuperación";
            }
            return(View());
        }
        public async Task <IActionResult> Create(RegistroViewModel model)
        {
            if (ModelState.IsValid)
            {
                Usuario usuario = new Usuario();
                usuario.NombreUsuario = model.Username;
                usuario.Correo        = model.Correo;
                usuario.Salt          = UtilsMethods.GenerarSalt();
                usuario.Contrasenia   = Crypto.HashPassword(model.Contrasenia + usuario.Salt);
                usuario.IdRol         = 2;
                usuario.FechaModifica = DateTime.Now;
                usuario.IpModifica    = Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString();

                _context.Add(usuario);
                await _context.SaveChangesAsync();

                int ultimoUsuario = _context.Usuarios.
                                    OrderByDescending(u => u.IdUsuario).FirstOrDefault().IdUsuario;

                Cliente cliente = new Cliente();
                cliente.Nombre        = model.Nombres;
                cliente.Apellidos     = model.Apellidos;
                cliente.Direccion     = model.Direccion;
                cliente.Genero        = model.Genero;
                cliente.IdUsuario     = ultimoUsuario;
                cliente.FechaModifica = DateTime.Now;
                cliente.IpModifica    = Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString();

                _context.Add(cliente);
                await _context.SaveChangesAsync();

                UtilsMethods.EnviarCorreo(usuario);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(model));
        }
Exemple #3
0
        public async Task <IActionResult> Recuperacion(RecuperacionViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var usuario = await _context.RecuperaContrasenias.Include(u => u.IdUsuarioNavigation)
                          .FirstOrDefaultAsync(u => u.Token == model.Token);

            if (usuario != null)
            {
                if (usuario.IdUsuarioNavigation != null)
                {
                    Usuario user = usuario.IdUsuarioNavigation;
                    user.Salt          = UtilsMethods.GenerarSalt();
                    user.Contrasenia   = CryptoHelper.Crypto.HashPassword(model.Contrasenia + user.Salt);
                    user.FechaModifica = DateTime.Now;
                    user.IpModifica    = Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString();

                    usuario.Token = "Expired";
                    _context.Update(usuario);
                    _context.Update(user);
                    await _context.SaveChangesAsync();

                    ViewBag.Message = "Contraseña modificada con éxito";
                    return(View(nameof(Index)));
                }
            }
            else
            {
                ViewBag.Error = "Token no válido";
                return(View("Index"));
            }

            return(View(model));
        }
 private void AddPurchasePrice(String Price)
 {
     UtilsMethods.WaitTextToBePresentInElement(KFIMainPageTittle, "");
     PurchasePrice.SendKeys(Price);
 }
 private void AddSurname() => SurnameField.SendKeys(UtilsMethods.RandomString(10));
 private void AddFirstName() => FirstNameField.SendKeys(UtilsMethods.RandomString(10));
 private void SelectNumbersOfApplicants(String Number)
 {
     UtilsMethods.WaitTextToBePresentInElement(KFITitlePage, "");
     NumbersOfApplicants(Convert.ToInt32(Number)).Click();
 }
        private void OnLoaded(string obj)
        {
            ParticipantList.Add(new ClientModel {
                Id = FIRST_PARTICIPANT, TitleName = "(空)", IsSelected = false
            });
            foreach (Participant person in AppContext.Default.MeetingDetail.Participants)
            {
                if ((person.TitleGroup == 0 || person.TitleGroup == 1 || person.TitleGroup == 2) &&
                    !(UtilsMethods.Decrypt(person.Name) == "原告席") &&
                    !(UtilsMethods.Decrypt(person.Name) == "被告席"))
                {
                    ParticipantList.Add(new ClientModel
                    {
                        Id         = person.Id,
                        TitleName  = person.Title + "-" + UtilsMethods.Decrypt(person.Name),
                        TitleGroup = person.TitleGroup,
                        Title      = person.Title,
                        Name       = UtilsMethods.Decrypt(person.Name),
                    });
                }
            }
            clientModelsList = ParticipantList.ToList();
            ClientModel clientModel = clientModelsList[0];

            MicrophoneList = new ObservableCollection <MicrophoneModel>
            {
                new MicrophoneModel {
                    MicrophoneId = "(1)", MicPort = ConfigFile.micPort1of9, SelectedClient = clientModel
                },
                new MicrophoneModel {
                    MicrophoneId = "(2)", MicPort = ConfigFile.micPort2of9, SelectedClient = clientModel
                },
                new MicrophoneModel {
                    MicrophoneId = "(3)", MicPort = ConfigFile.micPort3of9, SelectedClient = clientModel
                },
                new MicrophoneModel {
                    MicrophoneId = "(4)", MicPort = ConfigFile.micPort4of9, SelectedClient = clientModel
                },
                new MicrophoneModel {
                    MicrophoneId = "(5)", MicPort = ConfigFile.micPort5of9, SelectedClient = clientModel
                },
                new MicrophoneModel {
                    MicrophoneId = "(6)", MicPort = ConfigFile.micPort6of9, SelectedClient = clientModel
                },
                new MicrophoneModel {
                    MicrophoneId = "(7)", MicPort = ConfigFile.micPort7of9, SelectedClient = clientModel
                },
                new MicrophoneModel {
                    MicrophoneId = "(8)", MicPort = ConfigFile.micPort8of9, SelectedClient = clientModel
                },
                new MicrophoneModel {
                    MicrophoneId = "(9)", MicPort = ConfigFile.micPort9of9, SelectedClient = clientModel
                },
            };
            _asrManager = AsrServerManager.GetInstance(_nemo, _dataService, _eventAggregator);
            List <string> res = _asrManager.GetAsrMicrophoneConfig();

            if (res != null && res.Count > 0)
            {
                for (int i = 0; i < res.Count; i++)
                {
                    MicrophoneList[i].TitleName = res[i];
                    string title = string.Empty, name = string.Empty;
                    ConvertString2TitleName(res[i], ref title, ref name);
                    MicrophoneList[i].Title = title;
                    MicrophoneList[i].Name  = name;
                    ClientModel clientSelected = clientModelsList.FirstOrDefault(x => x.Id != FIRST_PARTICIPANT && x.Title.Equals(title) && x.Name.Equals(name));
                    if (clientSelected != null)
                    {
                        clientSelected.IsSelected        = true;
                        MicrophoneList[i].SelectedClient = clientSelected;
                    }
                }
                ParticipantList = new ObservableCollection <ClientModel>(clientModelsList);
            }
            InitDeviceList();
        }