Esempio n. 1
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WerkbonpersoneelExists(Werkbonpersoneel.PersoneelID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Esempio n. 2
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            try
            {
                // Use function if werkbon.image exist
                if (!String.IsNullOrEmpty(Werkbon.Image))
                {
                    var base64Signature = Werkbon.Image.Split(",")[1];
                    var binarySignature = Convert.FromBase64String(base64Signature);

                    System.IO.File.WriteAllBytes("wwwroot/images/" + Werkbon.Guid + ".png", binarySignature);
                }

                // Use function if werkbon.imageSecond exist
                if (!String.IsNullOrEmpty(Werkbon.ImageSecond))
                {
                    var base64SignatureSecond = Werkbon.ImageSecond.Split(",")[1];
                    var binarySignatureSecond = Convert.FromBase64String(base64SignatureSecond);

                    System.IO.File.WriteAllBytes("wwwroot/images/" + Werkbon.GuidSecond + ".png", binarySignatureSecond);
                }

                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WerkbonExists(Werkbon.WerkbonID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

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