Exemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            string repeatPassword = Request.Form["repeat-passwd"];
            string password       = Client.Password;
            string aceitar        = Request.Form["concordar"];

            var cli = await _context.Client.FirstOrDefaultAsync(m => m.Login == Client.Login);

            if (!string.Equals(password, repeatPassword) || password.Length < 8 || cli != null || aceitar == null)
            {
                return(RedirectToPage("/Erros"));
            }

            Hash hash = new Hash(SHA512.Create());

            // generate password hash SHA512

            Client.Password = hash.CriptografarSenha(Client.Password);

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

            return(RedirectToPage("Index"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Company).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CompanyExists(Company.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Companies.Add(Company);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Client = await _context.Client.FindAsync(id);

            if (Client != null)
            {
                _context.Client.Remove(Client);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }