Exemplo n.º 1
0
        // To protect from overposting attacks, 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(Doctor).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DoctorExists(Doctor.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync(string[] selectedAppointments)
        {
            var newChildren = new Children();

            if (selectedAppointments != null)
            {
                newChildren.Appointments = new List <Appointment>();
                foreach (var cat in selectedAppointments)
                {
                    var catToAdd = new Appointment
                    {
                        AvailableTimeDateID = int.Parse(cat)
                    };
                    newChildren.Appointments.Add(catToAdd);
                }
            }
            if (await TryUpdateModelAsync <Children>(
                    newChildren,
                    "Children",
                    i => i.FirstName, i => i.LastName, i => i.Address, i => i.CNP, i => i.PhoneNumber,
                    i => i.Insurance, i => i.DoctorID))
            {
                _context.Children.Add(newChildren);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            PopulateAssignedAvailabilityData(_context, newChildren);
            return(Page());
        }
Exemplo n.º 3
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync(int?id, string[] selectedAppointments)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var childrenToUpdate = await _context.Children
                                   .Include(i => i.Doctor)
                                   .Include(i => i.Appointments)
                                   .ThenInclude(i => i.AvailableTimeDate)
                                   .FirstOrDefaultAsync(s => s.ID == id);

            if (childrenToUpdate == null)
            {
                return(NotFound());
            }
            if (await TryUpdateModelAsync <Children>(
                    childrenToUpdate,
                    "Children",
                    i => i.FirstName, i => i.LastName, i => i.Address, i => i.CNP, i => i.PhoneNumber,
                    i => i.Insurance, i => i.Doctor))
            {
                UpdateAvailableHoursAndDates(_context, selectedAppointments, childrenToUpdate);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            UpdateAvailableHoursAndDates(_context, selectedAppointments, childrenToUpdate);
            PopulateAssignedAvailabilityData(_context, childrenToUpdate);
            return(Page());
        }
Exemplo n.º 4
0
        // To protect from overposting attacks, 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.Doctor.Add(Doctor);
            await _context.SaveChangesAsync();

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

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

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

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

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

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

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

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

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

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