public async Task <IActionResult> Edit(int id, [Bind("firstName,FamousPeopleId,lastName,birthDate,city,state")] FamousPeople famousPeople) { if (id != famousPeople.FamousPeopleId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(famousPeople); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FamousPeopleExists(famousPeople.FamousPeopleId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(famousPeople)); }
public async Task <IActionResult> Create(FamousPeople famousPeople) { if (ModelState.IsValid) { Services.FamousPeopleService.CreateFamousPeople(famousPeople); _context.Add(famousPeople); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(famousPeople)); }
//static readonly AppDbContext _context; public static int CreateFamousPeople(FamousPeople cmd) { var fp = new FamousPeople { firstName = cmd.firstName, FamousPeopleId = cmd.FamousPeopleId, lastName = cmd.lastName, birthDate = cmd.birthDate, city = cmd.city, state = cmd.state, Achievements = cmd.Achievements?.Select(i => new Achievements { AchievementsId = i.AchievementsId, FamousPeopleId = i.FamousPeopleId, name = i.name, doa = i.doa }).ToList() }; // _context.Add(fp); // _context.SaveChanges(); return(fp.FamousPeopleId); }
public IActionResult Add([FromBody] FamousPeople famousPeople) { return(Ok()); }
public static IEnumerable <string> RetrieveExampleList(string word) { word = word.ToLower(); if (!word.StartsWith("something")) { if (word.StartsWith("the title") || word.StartsWith("a title")) { word = word.Replace("the title ", string.Empty).Replace("a title ", string.Empty); } else { Regex firstWordRegex = new Regex(@"^\w+ "); word = firstWordRegex.Replace(word, ""); word = word.Replace("type of ", string.Empty); word = word.Replace("kind of ", string.Empty); } } switch (word) { case "noun": return(Nouns.Take(3)); case "adjective": return(Adjectives.Take(3)); case "plural noun": case "noun (plural)": return(PluralNouns.Take(3)); case "verb": return(Verbs.Take(3)); case "number": Random rand = new Random(); return(new List <string>() { rand.Next(1, 999).ToString(), rand.Next(1, 999).ToString(), rand.Next(1, 999).ToString() }); case @"verb ending in ""ing""": return(GerundVerbs.Take(3)); case "adverb": return(Adverbs.Take(3)); case "part of the body": case "body part": return(PartsOfBody.Take(3)); case "liquid": return(Liquids.Take(3)); case "place": return(Places.Take(3)); case "animal": return(Animals.Take(3)); case "food": return(Foods.Take(3)); case "color": return(Colors.Take(3)); case "verb (past tense)": return(PastTenseVerbs.Take(3)); case "celebrity": return(Celebrities.Take(3)); case "exclamation": return(Exclamations.Take(3)); case "part of the body (plural)": case "body part (plural)": return(PluralBodyParts.Take(3)); case "silly word": return(SillyWords.Take(3)); case "animal (plural)": return(PluralAnimals.Take(3)); case "city": return(Cities.Take(3)); case "nonsense word": return(NonsenseWords.Take(3)); case "famous person": return(FamousPeople.Take(3)); case "article of clothing": return(Clothing.Take(3)); case "vehicle": return(Vehicles.Take(3)); case "something alive (plural)": return(PluralAliveSomethings.Take(3)); case "geographical location": return(GeographicalLocations.Take(3)); case "town": return(Towns.Take(3)); case "country": return(Countries.Take(3)); case "container": return(Containers.Take(3)); case "last name": return(LastNames.Take(3)); case "name": return(Names.Take(3)); case @"verb ending in ""s""": return(VerbsEndingInS.Take(3)); case "occupation": case "occupation or job": case "profession": return(Occupations.Take(3)); case "silly noise": return(SillyNoises.Take(3)); case "male celebrity": case "celebrity (male)": return(MaleCelebrities.Take(3)); case "article of clothing (plural)": return(PluralClothing.Take(3)); case "name of a school": case "school": return(Schools.Take(3)); case "building": return(Buildings.Take(3)); case "bird": return(Birds.Take(3)); case @"adjective ending in ""est""": case "adjective (superlative)": return(Superlatives.Take(3)); case "letter": return(Letters.Take(3)); case "game": return(Games.Take(3)); case "holiday": return(Holidays.Take(3)); case "silly word (plural)": return(PluralSillyWords.Take(3)); case "something round": return(RoundSomethings.Take(3)); case "piece of furniture": return(Furniture.Take(3)); case "vegetable": return(Vegetables.Take(3)); case "spanish word": return(SpanishWords.Take(3)); case "tv actor": return(TVActors.Take(3)); case "boy's name": return(BoyNames.Take(3)); case "something alive": return(AliveSomethings.Take(3)); case "female celebrity": case "celebrity (female)": return(FemaleCelebrities.Take(3)); case "italian word": return(ItalianWords.Take(3)); case "occupation (plural)": return(PluralOccupations.Take(3)); case "first name": return(FirstNames.Take(3)); case "room in a house": return(HouseRooms.Take(3)); case "relative": return(Relatives.Take(3)); case "movie star": return(MovieStars.Take(3)); case "disease": return(Diseases.Take(3)); case "sport": return(Sports.Take(3)); case "something icky": return(IckySomethings.Take(3)); case "actor": return(Actors.Take(3)); case "concept or ideal": return(Concepts.Take(3)); default: return(new string[3] { string.Empty, string.Empty, string.Empty }); } }