예제 #1
0
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyVolunteer = new Volunteer();

            if (await TryUpdateModelAsync <Volunteer>(
                    emptyVolunteer,
                    "Volunteer", // Prefix for form value.
                    s => s.VDocCPF,
                    s => s.VDocRG,
                    s => s.VName,
                    s => s.VBirthDate,
                    s => s.VResumee,
                    s => s.VPhone,
                    s => s.VMessagePhone,
                    s => s.VEmail,
                    s => s.VSocialMidiaProfile,
                    s => s.VActive,
                    s => s.AddressId))
            {
                emptyVolunteer.AgeCalculator();
                _context.Volunteer.Add(emptyVolunteer);
                await _context.SaveChangesAsync();

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

            return(Page());
        }