public IActionResult Create(Experience experience) { db.Experiences.Add(experience); db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult Create(Person person) { //var id = @ViewBag.ExperienceId; db.People.Add(person); db.SaveChanges(); return(RedirectToAction("Details", "Experiences", new { id = person.ExperienceId })); }
public IActionResult Edit(Person person) { int ExperienceId = person.ExperienceId; db.Entry(person).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { id = ExperienceId })); }
public IActionResult NewPerson(string newName) { Person newPerson = new Person(newName); db.People.Add(newPerson); db.SaveChanges(); return(Json(Url.Action("Index", "People"))); }
public IActionResult Delete(string RoleId) { var thisRole = _db.Roles.FirstOrDefault(r => r.Id == RoleId); _db.Roles.Remove(thisRole); _db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult Edit(Experience experience) { int Locationid = experience.LocationId; db.Entry(experience).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { id = Locationid })); }
public async Task <IActionResult> Create(Location location) { var userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var currentUser = await _userManager.FindByIdAsync(userId); location.User = currentUser; _db.Locations.Add(location); _db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult AddToLocation(PersonAtLocation formResults) { Person newPerson = new Person(); newPerson.Name = formResults.PersonName; newPerson.LocationId = formResults.Location.LocationId; db.People.Add(newPerson); db.SaveChanges(); return(RedirectToAction("Details", "Home", new { id = formResults.Location.LocationId })); }
public IActionResult AddToLocation(ExperienceAtLocation formResults) { Experience newExperience = new Experience(); newExperience.Name = formResults.ExperienceName; newExperience.Description = formResults.ExperienceDescription; newExperience.LocationId = formResults.Location.LocationId; db.Experiences.Add(newExperience); db.SaveChanges(); return(RedirectToAction("Details", "Home", new { id = formResults.Location.LocationId })); }
public async Task <IActionResult> Create(Experience experience, int locationId) { var userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var currentUser = await _userManager.FindByIdAsync(userId); var thisLocation = _db.Locations.FirstOrDefault(locations => locations.LocationId == locationId); experience.Location = thisLocation; experience.User = currentUser; _db.Experiences.Add(experience); _db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create(Suggestion suggestion, int locationId) { var userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var currentUser = await _userManager.FindByIdAsync(userId); suggestion.User = currentUser; var thisLocation = _db.Locations.FirstOrDefault(locations => locations.LocationId == locationId); suggestion.Location = thisLocation; suggestion.Visted = false; suggestion.UpVote = 0; _db.Suggestions.Add(suggestion); _db.SaveChanges(); return(RedirectToAction("Index")); }
private static void AddTestData(TravelBlogContext context) { var testUser1 = new Models.Person { Name = "Elise" }; context.People.Add(testUser1); var testExperience = new Models.Experience { Name = "Go to the beach", Story = "It was awesome", PersonId = 1, PlaceId = 1 }; context.Experiences.Add(testExperience); var testLocation = new Models.Place { Name = "Los Angeles" }; context.Places.Add(testLocation); context.SaveChanges(); }
public IActionResult NewDestination(string newCity, string newCountry) { Destination newDestination = new Destination(newCity, newCountry); db.Destinations.Add(newDestination); db.SaveChanges(); return(Json(newDestination)); }
public IActionResult Create(Comment comment) { //We need to get access to the userId and the targetId here somehow _db.Comments.Add(comment); _db.SaveChanges(); //this return line needs to Redirect not to index but back to the particular detail view return(RedirectToAction("Index")); }
public IActionResult Create(Comment comment, int locationId) { comment.LocationId = locationId; System.Diagnostics.Debug.WriteLine(locationId); System.Diagnostics.Debug.WriteLine(comment.LocationId); db.Comments.Add(comment); db.SaveChanges(); return(RedirectToAction("Details", "Locations", new { id = comment.LocationId })); }
public ActionResult Create(string RoleName) { try { _db.Roles.Add(new IdentityRole() { Name = RoleName, NormalizedName = RoleName.ToUpper() }); _db.SaveChanges(); ViewBag.ResultMessage = "Role created successfully !"; return(RedirectToAction("Index")); } catch { return(View()); } }
public IActionResult Create(Comment comment, int locationId) { string userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; ApplicationUser user = db.Users.FirstOrDefault(u => u.Id == userId); comment.LocationId = locationId; comment.AppUser = user; db.Comments.Add(comment); db.SaveChanges(); return(RedirectToAction("Details", "Locations", new { id = comment.LocationId })); }
public async Task <IActionResult> Create(Comment comment, int id) { var userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var currentUser = await _userManager.FindByIdAsync(userId); comment.User = currentUser; comment.Experience = _db.Experiences.FirstOrDefault(Experiences => Experiences.ExperienceId == id); _db.Comments.Add(comment); _db.Database.ExecuteSqlCommand("SET IDENTITY_INSERT Comments ON"); _db.SaveChanges(); _db.Database.ExecuteSqlCommand("SET IDENTITY_INSERT Comments OFF"); return(RedirectToAction("Details", "Experience", new { id = id })); }
public void Post([FromBody] Destination destination) { _db.Destinations.Add(destination); _db.SaveChanges(); }
public IActionResult Create(Person person) { db.Persons.Add(person); db.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public IActionResult Create(Location location) { db.Locations.Add(location); db.SaveChanges(); return RedirectToAction("Index"); }
public IActionResult Create(Place place) { db.Places.Add(place); db.SaveChanges(); return(RedirectToAction("Index")); }
public Location Save(Location location) { db.Locations.Add(location); db.SaveChanges(); return(location); }
public IActionResult Create(Location location) { db.Locations.Add(location); db.SaveChanges(); return(RedirectToAction("Create", "Experiences")); }
public IActionResult Create(People people) { db.People.Add(people); db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult Create(Person Person, int locationId) { db.People.Add(Person); db.SaveChanges(); return(RedirectToAction("Index", "Location")); }
public IActionResult Create(Experience experience) { db.Experiences.Add(experience); db.SaveChanges(); return(RedirectToAction("Details", "Locations", new { id = experience.LocationId })); }
public Suggestion Save(Suggestion suggestion) { db.Suggestions.Add(suggestion); db.SaveChanges(); return(suggestion); }
public ActionResult Create(Review review) { _db.Reviews.Add(review); _db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult Create(Trip trip) { db.Trips.Add(trip); db.SaveChanges(); return(RedirectToAction("Index")); }