示例#1
0
        public IActionResult Create(Experience experience)
        {
            db.Experiences.Add(experience);

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#2
0
 public IActionResult Create(Person person)
 {
     //var id = @ViewBag.ExperienceId;
     db.People.Add(person);
     db.SaveChanges();
     return(RedirectToAction("Details", "Experiences", new { id = person.ExperienceId }));
 }
示例#3
0
        public IActionResult Edit(Person person)
        {
            int ExperienceId = person.ExperienceId;

            db.Entry(person).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index", new { id = ExperienceId }));
        }
示例#4
0
        public IActionResult NewPerson(string newName)
        {
            Person newPerson = new Person(newName);

            db.People.Add(newPerson);
            db.SaveChanges();
            return(Json(Url.Action("Index", "People")));
        }
示例#5
0
        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 }));
        }
示例#7
0
        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 }));
        }
示例#9
0
        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 }));
        }
示例#10
0
        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"));
        }
示例#11
0
        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"));
        }
示例#12
0
        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();
        }
示例#13
0
        public IActionResult NewDestination(string newCity, string newCountry)
        {
            Destination newDestination = new Destination(newCity, newCountry);

            db.Destinations.Add(newDestination);
            db.SaveChanges();
            return(Json(newDestination));
        }
示例#14
0
 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 }));
 }
示例#16
0
 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();
 }
示例#20
0
 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");
 }
示例#22
0
 public IActionResult Create(Place place)
 {
     db.Places.Add(place);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
示例#23
0
 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"));
 }
示例#25
0
 public IActionResult Create(People people)
 {
     db.People.Add(people);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
示例#26
0
 public IActionResult Create(Person Person, int locationId)
 {
     db.People.Add(Person);
     db.SaveChanges();
     return(RedirectToAction("Index", "Location"));
 }
示例#27
0
 public IActionResult Create(Experience experience)
 {
     db.Experiences.Add(experience);
     db.SaveChanges();
     return(RedirectToAction("Details", "Locations", new { id = experience.LocationId }));
 }
示例#28
0
 public Suggestion Save(Suggestion suggestion)
 {
     db.Suggestions.Add(suggestion);
     db.SaveChanges();
     return(suggestion);
 }
示例#29
0
 public ActionResult Create(Review review)
 {
     _db.Reviews.Add(review);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
示例#30
0
 public IActionResult Create(Trip trip)
 {
     db.Trips.Add(trip);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }