Beispiel #1
0
        public async Task <IActionResult> Create([Bind("FamilyId,FamilyName,FamilyLatin")] Family family)
        {
            if (ModelState.IsValid)
            {
                string familyName = family.FamilyName;

                string familyTitleCase =
                    System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.
                    ToTitleCase(familyName.ToLower());

                family.FamilyName = familyTitleCase;

                string latin = family.FamilyLatin;

                string latinTitleCase =
                    System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.
                    ToTitleCase(latin.ToLower());

                family.FamilyLatin = latinTitleCase;

                _context.Add(family);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(family));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("PlantId,PlantName,Latin,Level,Family,Care")] Plant plant)
        {
            if (ModelState.IsValid)
            {
                string myText = plant.PlantName;

                string asTitleCase =
                    System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.
                    ToTitleCase(myText.ToLower());

                plant.PlantName = asTitleCase;

                string latin = plant.Latin;

                string latinTitleCase =
                    System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.
                    ToTitleCase(latin.ToLower());

                plant.Latin = latinTitleCase;

                _context.Add(plant);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Care"]   = new SelectList(_context.Care, "CareId", "CareId", plant.Care);
            ViewData["Family"] = new SelectList(_context.Family, "FamilyId", "FamilyLatin", plant.Family);
            return(View(plant));
        }