Professional Documents
Culture Documents
________________________________________________________________
FINAL REPORT
Task number 01
Solution:
We first have to create a new class named Medicines in the Model folder.
Then we will create different properties and attributes according to the
requirements of JSON data file.
Here is the code for Model of Web application.
using System.Text.Json;
using System.Text.Json.Serialization;
namespace MedicineDeliveryWebApp.Models
{
public class Medicines
{
[JsonPropertyName(“id”)]
[JsonPropertyName(“brand”)]
[JsonPropertyName(“Formula”)]
[JsonPropertyName(“Category”)]
return JsonSerializer.Serialize<Medicines>(this);
}
Task number 02
Solution:
[ForeignKey(“MedicinesSeller”)]
Model File and have to added the following code. Also , we have to create a
using System.ComponentModel.DtaAnnotations;
namespace MedicinesDeliveryWebApp.Models
{
public class Seller
[Key]
[Required]
Task number 03
Solution:
namespace MedicinesDeliveryWebApp.Services
WebHostEnvironment = webHostEnvironment;
get
"medicines.json");
return JsonSerializer.Deserialize<Medicine[]>(jsonFile.ReadToEnd());
}
Task number 04
Solution:
<h1 class="display-4">Welcome</h1>
</div>
<ul>
</ul>
<li>@medicine.medicineBrand</li>
Then we have to made some amendments to Index Model code as well as
public
JsonFileMedicineService(IWebHostEnvironment webHostEnvironment)
WebHostEnvironment webHostEnvironment;
get {
}
return Path.Combine(WebHostEnvironment.WebRootPath, "data",
"data", "Medicines.json");
Task number 05
web application that gives a list of items data that are stored in
JSON format.
Solution:
Task number 06
Solution:
using MedicinesDeliveryWebApp.Models;
namespace MedicinesDeliveryWebApp.Controllers
[Route("api/[controller]")]
[ApiController]
[HttpGet]
return stylesheetService.getStyleSheet();
using ComputerShoppingWebApp.Models;
using System.Text.Json;
namespace ComputerShoppingWebApp.Services
}
WebHostEnvironment webHostEnvironment;
get
{
return Path.Combine(WebHostEnvironment.WebRootPath, "css",
"StyleSheet.css");
}
public string getStylesheet()
{
return cssFile.ReadToEnd();
Task number 07
Create the input form and form handler for your data.
Solution:
We created the controller for the form handler and view for input form,
and wrote the following code:
<div class="text-center">
<h1 class="display-4">welcome</h1>
</div>
<br />
Task number 08
Create the Search Form for your web application project.
Solution:
<h4>Book Search</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="SearchResult">
<div asp-validation-summary="ModelOnly" class="text-danger"></div> <div
class="form-group">
</div>
<div class="form-group">
</div>
</form>
</div>
</div>
Task number 09
Add user authentication to your project.
Solution:
@model IEnumerable<MedicinesDeliveryWebApp.Models.Medicines>
<div class="text-center">
</div>
<div class="row">
{
<div class="col-lg-3 col-md-6 col-sm-12′′ style="margin-bottom: 78px;">
</div>
</div>
Also made some additional changes in different files where authentication was
needed.
For example, in the details file we made the following changes:
@model
@using
MedicinesDeliveryWebApp.Models.Medicines
Microsoft.AspNetCore.Identity
ViewData["Title"] = "Details"
@@ -43,6 +47,9 @e
</dl>
</div>
<div>
<a asp-action="Edit" asp-route-id="@Model.ID">Edit</a> | @if
(SignInManager.IsSignedIn(User)) {
}
<a asp-action="Edit" asp-route-id="@Model.ID">Edit</a> <br />
<a asp-action="Index">Back to List</a> </div>
THANK YOU
__________________________________________________
__________