Ejemplo n.º 1
0
        public async Task <IActionResult> OnPostAdd()
        {
            int IdT = Int32.Parse(Request.Form["Things.NazwaArtykulu"]);

            if (_context.DocumentsThings.Any(dt => dt.IdFkd == Documents.Id && dt.IdFkt == IdT))
            {
                var update = _context.DocumentsThings.First(dt => dt.IdFkd == Documents.Id && dt.IdFkt == IdT);
                update.Ilosc += DocumentsThings.Ilosc;
            }
            else
            {
                var create = new DocumentsThings()
                {
                    IdFkd = Documents.Id,
                    IdFkt = IdT,   //Int32.Parse(Request.Form["Things.NazwaArtykulu"]),
                    Ilosc = DocumentsThings.Ilosc
                };

                int a = 1;

                _context.Entry(create).State = EntityState.Added;
            }


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

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


            //var hash = PasswordHash.ArgonHashString(yourPasswordString, Strength.Interactive)
            //if (PasswordHash.ArgonHashStringVerify(hash, yourPasswordString) {
            //}

            var create = new Users()
            {
                Name     = Users.Name,
                Login    = Users.Login,
                Password = Users.Password
            };

            int a = 1;

            _context.Entry(create).State = EntityState.Added;



            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }

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