Blazor in Action by Chris Sainty
Author:Chris Sainty [Chris Sainty]
Language: eng
Format: epub
Publisher: Manning Publications
Published: 2022-06-19T00:00:00+00:00
6.4.3 Adding the edit trail feature
Before we start making any changes in the Client project to enable editing, we need to make some changes to the Shared project. There are a few jobs for us to do:
We must update the TrailDto classâspecifically, to handle updating the trail image.
We need to update the folder structure so it mirrors the feature folder structure in the Client project.
We need to add two new requests for our edit functionality: EditTrailRequest and GetTrailRequest.
Letâs work through each of these items, starting at the top.
Updating the TrailDto class
When editing a trail, we will need to be able to display the trailâs current image, if it has one. We will also need to give the user the ability to remove the image, update it, or leave it unchanged. To enable these scenarios, weâll update the class with two additional properties and a new enum, as shown in the following listing.
Listing 6.22 TrailDto.cs: Add new properties and ImageAction enum
public class TrailDto { // other properties omitted public string? Image { get; set; } ⶠpublic ImageAction ImageAction { get; set; } ⷠ} public enum ImageAction ⸠{ None, Add, Remove }
ⶠImage holds the filename of an existing image.
â· ImageAction allows us to set what operation to perform on the trail image when updating the trail.
⸠Contains the various operations that can be performed on an image
When we add the edit functionality to the Client project, we need to load the trail to edit from the API. At this point we need to know if the trail has an image. This is where the new Image property comes in. If there is an image, this will contain the filename of that image so we can display it to the user.
When the user is modifying a trail with an image, we need to know what operation, if any, weâre performing on that image. This is where the second new property and new enum come in. If they add or remove the image, we will record that intent using the ImageAction property. We can then reference this in our endpoint to understand what to do.
Updating the Shared projectâs folder structure
To keep things organized, we want to make sure we keep the same feature folder structure throughout the solution. Based on our changes in the Client project, we need to add three new folders in the ManageTrails folder:
AddTrail
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
ActiveX | ASP.NET |
Cold Fusion | CSS |
DHTML | Java Server Pages |
JavaScript | PHP |
Python | Ruby |
XSL |
Hello! Python by Anthony Briggs(9351)
The Mikado Method by Ola Ellnestam Daniel Brolund(9288)
Dependency Injection in .NET by Mark Seemann(8836)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7385)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7097)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(6233)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(5933)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5496)
Kotlin in Action by Dmitry Jemerov(4617)
Audition by Ryu Murakami(4076)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(3776)
Functional Programming in JavaScript by Mantyla Dan(3712)
Learning React: Functional Web Development with React and Redux by Banks Alex & Porcello Eve(2822)
Svelte with Test-Driven Development by Daniel Irvine(2564)
Architecting Modern Java EE Applications: Designing lightweight, business-oriented enterprise applications in the age of cloud, containers, and Java EE 8 by Daschner Sebastian(2547)
WordPress Plugin Development Cookbook by Yannick Lefebvre(2523)
React Native - Building Mobile Apps with JavaScript by Novick Vladimir(2326)
Layered Design for Ruby on Rails Applications by Dementyev Vladimir;(2222)
PHP 7 Data Structures and Algorithms by Mizanur Rahman(2193)