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)); }
public async Task <IActionResult> PutFamily(int id, Family family) { if (id != family.FamilyId) { return(BadRequest()); } _context.Entry(family).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FamilyExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPlant(int id, Plant plant) { if (id != plant.PlantId) { return(BadRequest()); } _context.Entry(plant).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlantExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
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)); }
public async Task <IActionResult> PutCare(int id, Care care) { if (id != care.CareId) { return(BadRequest()); } _context.Entry(care).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CareExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }