public async Task <IActionResult> Edit(int id, [Bind("PlantId,PlantName,Latin,Level,Family,Care")] Plant plant) { if (id != plant.PlantId) { return(NotFound()); } 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; try { _context.Update(plant); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlantExists(plant.PlantId)) { return(NotFound()); } else { throw; } } 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)); }
public async Task <IActionResult> Edit(int id, [Bind("FamilyId,FamilyName,FamilyLatin")] Family family) { if (id != family.FamilyId) { return(NotFound()); } 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; try { _context.Update(family); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FamilyExists(family.FamilyId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(family)); }