Beispiel #1
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var technician = await _context.Technician.FindAsync(id);


            if (technician == null)
            {
                return(NotFound());
            }

            try
            {
                _context.Technician.Remove(technician);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            catch (DbUpdateException /* ex */)
            {
                //Log the error (uncomment ex variable name and write a log.)
                return(RedirectToAction("./Delete",
                                        new { id, saveChangesError = true }));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyTechnician = new Technician();

            if (await TryUpdateModelAsync <Technician>(
                    emptyTechnician,
                    "technician", // Prefix for form value.
                    s => s.PNumber, s => s.LastName, s => s.FirstName
                    ))

            {
                _context.Technician.Add(emptyTechnician);
                await _context.SaveChangesAsync();

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



            return(null);
        }
Beispiel #3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var technicianToUpdate = await _context.Technician.FindAsync(id);

            if (await TryUpdateModelAsync <Technician>(
                    technicianToUpdate,
                    "technician",
                    s => s.PNumber, s => s.LastName, s => s.FirstName))
            {
                await _context.SaveChangesAsync();

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


            return(Page());
        }