public IActionResult Edit(int id, [Bind("Id,Name,Phone")] MedicalCentre medicalCentre)
        {
            if (id != medicalCentre.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(medicalCentre);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MedicalCentreExists(medicalCentre.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(medicalCentre));
        }
 public IActionResult Create([Bind("Id,Name,Phone")] MedicalCentre medicalCentre)
 {
     if (ModelState.IsValid)
     {
         _context.Add(medicalCentre);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(medicalCentre));
 }
Beispiel #3
0
        //Gets the centre information form  .uses a lamda query to select the
        //Centre infromation.
        public IActionResult OnGet(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            MedicalCentre = _context.MedicalCentre.FirstOrDefault(m => m.Id == id);

            if (MedicalCentre == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Beispiel #4
0
        //Removes a centre uses a linq query to check presence.
        public IActionResult OnPost(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            MedicalCentre = (from centre in _context.MedicalCentre
                             where centre.Id == id
                             select centre
                             ).FirstOrDefault();

            if (MedicalCentre != null)
            {
                _context.MedicalCentre.Remove(MedicalCentre);
                _context.SaveChanges();
            }

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