Exemple #1
0
        public async Task <IActionResult> Create([Bind("Id,Name,Type")] Centre centre)
        {
            if (ModelState.IsValid)
            {
                _context.Add(centre);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Type"] = new List <SelectListItem> {
                new SelectListItem {
                    Text = AdoptionCentreString, Value = AdoptionCentreString
                }, new SelectListItem {
                    Text = CleansingCentreString, Value = CleansingCentreString
                }
            };
            return(View(centre));
        }
        public async Task <IActionResult> Register([Bind("Id,Name,Breed,IntelligenceCoefficient,Cleansed,CentreId")] Cat cat)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cat);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Cleansed"] = new List <SelectListItem> {
                new SelectListItem {
                    Text = "Yes", Value = "1"
                }, new SelectListItem {
                    Text = "No", Value = "0"
                }
            };
            ViewData["CentreId"] = new SelectList(_context.Centres.Where(c => c.Type == AdoptionCentreString), "Id", "Name", cat.CentreId);
            return(View(cat));
        }