It does go to the proper if/else statements and displays what I want it to. It's just that after it hits update, it just doesn't actually update. It's actually creating a new record. Is this potentially an issue with Entity Framework?
Could that possibly be a typo? In other parts of the API, the symbols are directly in there. It's just the name that's like that.
Also, yes, decoding did the job, so thank you for this!
park.ParkName = HttpUtility.HtmlDecode(individualPark.FullName);
Do you know why .Update would be duplicating a record?
I am running the REST call to save info to my Parks database, but before I save it, I am checking the park code to see if it's already in the database. Is this even the right code? It does hit the else statement, content just doesn't get...
I am using the National Park Service REST API to pull park info which I am saving to a SQL database. It saves with the unicode value. One of the parks in Hawai'i is Haleakalā National Park, which is fine, only whenever I want it to display, it shows exactly that unicode and not the actual...
private readonly IPeopleService _peopleService;
public PeopleController(IPeopleService peopleService)
{
_peopleService = peopleService;
}
Sorry, copy and pasted. This is what it should be
Figured it out. It was a syntax thing.
Error on the Controller
Should have been:
public PeopleController(IPeopleService _peopleService)
{
_peopleService = peopleService;
}
I was referencing the actual service, and not the interface
Yeah, sorry, there actually is no underscore in the parameter.
So is it wrong in saying the order should be
1. Inject services in the Startup file that connects to the specific service interface and service class
2. Create a service that inherits from the interface and run the required method...
I am just creating services for the first time, and my application errors out whenever I try to go to the view of the controller I am working on.
A Service Interface for People:
public interface IPeopleService
{
List<Person> GetPeople();
}
The Service Itself:
public...
That makes sense.
So you still have 1 service layer for each model, right?
Then an additional service layer for models that share values from multiple models?
Thank you so much!
I am updating my .NET Core web app from just MVC to a Service-Repository pattern.
My question is, how do you implement DbSet<> when you add the Service and Repository layers?
I originally added these to my ApplicationDbContext file under the Data folder. Is this still correct? Then would I just...
-------------------------
Update:
Added a new list to allow the foreach loop to enumerate through
Updated Partial View:
@model walkinthepark.Models.HikerParkWishlist
<h3 class="text-center">National Parks Wishlist</h3>
@{
// Create an empty list for the marker values to add into...
I recently created a method to add items to a wishlist.
I am using Park and Hiker models, and the wishlist is created to combine values from both tables.
Information is saving to the Wishlist table just fine, but I am getting an error trying to loop through each record.
Park Model:
public...
That did it.
On my junction table:
public class HikerParkWishlist
{
public int HikerId { get; set; }
public Hiker Hiker { get; set; }
public int ParkId { get; set; }
public string ParkName { get; set; }
public Park Park { get; set; }
}...
I'm having issues trying to make a wishlist.
I have a database with records of National Parks.
I also have a database with records of Hikers.
I have a button on the Park details view page that is supposed to redirect to an action.
@Html.ActionLink("Add Park to Wish List", "AddParkToWishList"...
That's actually a mistake. I will have them redirect to the main home page after deleting. I don't have roles set up yet. I've only done that with Framework.
Is there an issue will allowing a registered user to delete their own record?
That did it.
Added to the top of my controller and constructor:
private readonly SignInManager<IdentityUser> _signInManager;
public PeopleController(ApplicationDbContext context, SignInManager<IdentityUser> signInManager)
{
_context = context;
_signInManager = signInManager;
}
A...
Perhaps. How would you go about doing that?
Do you have to get the entire record you want to delete?
Or maybe just the email (the part that's still showing)?
public void Remove(string key)
{
Response.Cookies.Delete(key);
}
Something like that? Am I passing a single value, or a User Object?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.