first commit

This commit is contained in:
Adam Mikolajczak 2023-10-24 10:10:39 +02:00
commit 1c2b2cdf50
359 changed files with 93312 additions and 0 deletions

25
CRM.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34031.279
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CRM", "CRM\CRM.csproj", "{85AFAC1E-630F-4D18-AF80-6968C148FF56}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{85AFAC1E-630F-4D18-AF80-6968C148FF56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85AFAC1E-630F-4D18-AF80-6968C148FF56}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85AFAC1E-630F-4D18-AF80-6968C148FF56}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85AFAC1E-630F-4D18-AF80-6968C148FF56}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D6163BE0-E63A-4444-B705-4E065A60C41A}
EndGlobalSection
EndGlobal

22
CRM/CRM.csproj Normal file
View File

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.23">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.23" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.23">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.16" />
</ItemGroup>
</Project>

14
CRM/CRM.csproj.user Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_SelectedScaffolderID>ModelBasedCrudRazorPageScaffolder</_SelectedScaffolderID>
<_SelectedScaffolderCategoryPath>root/Common/RazorPage</_SelectedScaffolderCategoryPath>
<WebStackScaffolding_ViewDialogWidth>768.8</WebStackScaffolding_ViewDialogWidth>
<WebStackScaffolding_DbContextDialogWidth>650.4</WebStackScaffolding_DbContextDialogWidth>
<WebStackScaffolding_IsLayoutPageSelected>True</WebStackScaffolding_IsLayoutPageSelected>
<WebStackScaffolding_IsPartialViewSelected>False</WebStackScaffolding_IsPartialViewSelected>
<WebStackScaffolding_IsReferencingScriptLibrariesSelected>True</WebStackScaffolding_IsReferencingScriptLibrariesSelected>
<WebStackScaffolding_LayoutPageFile />
<WebStackScaffolding_DbContextTypeFullName>CRM.Data.CRMContext</WebStackScaffolding_DbContextTypeFullName>
</PropertyGroup>
</Project>

19
CRM/Data/CRMContext.cs Normal file
View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using CRM.Models;
namespace CRM.Data
{
public class CRMContext : DbContext
{
public CRMContext (DbContextOptions<CRMContext> options)
: base(options)
{
}
public DbSet<CRM.Models.Product> Product { get; set; } = default!;
}
}

View File

@ -0,0 +1,96 @@
// <auto-generated />
using System;
using CRM.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace CRM.Migrations
{
[DbContext(typeof(CRMContext))]
[Migration("20231023193417_InitialCreate")]
partial class InitialCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.23")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("CRM.Models.Category", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Category");
});
modelBuilder.Entity("CRM.Models.Product", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<int>("CategoryId")
.HasColumnType("int");
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<int>("CreatorUserID")
.HasColumnType("int");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ImageUrl")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("CategoryId");
b.ToTable("Product");
});
modelBuilder.Entity("CRM.Models.Product", b =>
{
b.HasOne("CRM.Models.Category", "Category")
.WithMany()
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Category");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,65 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CRM.Migrations
{
public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Category",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Category", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Product",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorUserID = table.Column<int>(type: "int", nullable: false),
ImageUrl = table.Column<string>(type: "nvarchar(max)", nullable: false),
CategoryId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Product", x => x.Id);
table.ForeignKey(
name: "FK_Product_Category_CategoryId",
column: x => x.CategoryId,
principalTable: "Category",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Product_CategoryId",
table: "Product",
column: "CategoryId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Product");
migrationBuilder.DropTable(
name: "Category");
}
}
}

View File

@ -0,0 +1,94 @@
// <auto-generated />
using System;
using CRM.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace CRM.Migrations
{
[DbContext(typeof(CRMContext))]
partial class CRMContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.23")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("CRM.Models.Category", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Category");
});
modelBuilder.Entity("CRM.Models.Product", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<int>("CategoryId")
.HasColumnType("int");
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<int>("CreatorUserID")
.HasColumnType("int");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ImageUrl")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("CategoryId");
b.ToTable("Product");
});
modelBuilder.Entity("CRM.Models.Product", b =>
{
b.HasOne("CRM.Models.Category", "Category")
.WithMany()
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Category");
});
#pragma warning restore 612, 618
}
}
}

9
CRM/Models/Category.cs Normal file
View File

@ -0,0 +1,9 @@
namespace CRM.Models
{
public class Category
{
public string name;
public int Id { get; set; }
public string Name { get => name; set => name = value; }
}
}

15
CRM/Models/Comment.cs Normal file
View File

@ -0,0 +1,15 @@
namespace CRM.Models
{
public class Comment
{
private Product product;
public int Id { get; set; }
public Product Product { get => product; set => product = value; }
public string Description { get; set; }
public DateTime CreationDate { get; set; }
public bool IsDeleted { get; set; }
public int CreatorUserId { get; set; }
}
}

15
CRM/Models/Product.cs Normal file
View File

@ -0,0 +1,15 @@
namespace CRM.Models
{
public class Product
{
public int Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public bool IsDeleted { get; set; }
public DateTime CreationDate { get; set; }
public int CreatorUserID { get; set; }
public String ImageUrl { get; set; }
public Category Category { get; set; }
}
}

26
CRM/Pages/Error.cshtml Normal file
View File

@ -0,0 +1,26 @@
@page
@model ErrorModel
@{
ViewData["Title"] = "Error";
}
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>

27
CRM/Pages/Error.cshtml.cs Normal file
View File

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;
namespace CRM.Pages
{
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
private readonly ILogger<ErrorModel> _logger;
public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}
public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
}

10
CRM/Pages/Index.cshtml Normal file
View File

@ -0,0 +1,10 @@
@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<h1 class="display04">Time: @DateTime.Now</h1>
</div>

20
CRM/Pages/Index.cshtml.cs Normal file
View File

@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace CRM.Pages
{
public class IndexModel : PageModel
{
private readonly ILogger<IndexModel> _logger;
public IndexModel(ILogger<IndexModel> logger)
{
_logger = logger;
}
public void OnGet()
{
}
}
}

8
CRM/Pages/Privacy.cshtml Normal file
View File

@ -0,0 +1,8 @@
@page
@model PrivacyModel
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>
<p>Use this page to detail your site's privacy policy.</p>

View File

@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace CRM.Pages
{
public class PrivacyModel : PageModel
{
private readonly ILogger<PrivacyModel> _logger;
public PrivacyModel(ILogger<PrivacyModel> logger)
{
_logger = logger;
}
public void OnGet()
{
}
}
}

View File

@ -0,0 +1,59 @@
@page
@model CRM.Pages.Products.CreateModel
@{
ViewData["Title"] = "Create";
}
<h1>Create</h1>
<h4>Product</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="Product.Title" class="control-label"></label>
<input asp-for="Product.Title" class="form-control" />
<span asp-validation-for="Product.Title" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Product.Description" class="control-label"></label>
<input asp-for="Product.Description" class="form-control" />
<span asp-validation-for="Product.Description" class="text-danger"></span>
</div>
<div class="form-group form-check">
<label class="form-check-label">
<input class="form-check-input" asp-for="Product.IsDeleted" /> @Html.DisplayNameFor(model => model.Product.IsDeleted)
</label>
</div>
<div class="form-group">
<label asp-for="Product.CreationDate" class="control-label"></label>
<input asp-for="Product.CreationDate" class="form-control" />
<span asp-validation-for="Product.CreationDate" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Product.CreatorUserID" class="control-label"></label>
<input asp-for="Product.CreatorUserID" class="form-control" />
<span asp-validation-for="Product.CreatorUserID" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Product.ImageUrl" class="control-label"></label>
<input asp-for="Product.ImageUrl" class="form-control" />
<span asp-validation-for="Product.ImageUrl" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-primary" />
</div>
</form>
</div>
</div>
<div>
<a asp-page="Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

View File

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using CRM.Data;
using CRM.Models;
namespace CRM.Pages.Products
{
public class CreateModel : PageModel
{
private readonly CRM.Data.CRMContext _context;
public CreateModel(CRM.Data.CRMContext context)
{
_context = context;
}
public IActionResult OnGet()
{
return Page();
}
[BindProperty]
public Product Product { get; set; } = default!;
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid || _context.Product == null || Product == null)
{
return Page();
}
_context.Product.Add(Product);
await _context.SaveChangesAsync();
return RedirectToPage("./Index");
}
}
}

View File

@ -0,0 +1,58 @@
@page
@model CRM.Pages.Products.DeleteModel
@{
ViewData["Title"] = "Delete";
}
<h1>Delete</h1>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>Product</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Product.Title)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Product.Title)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Product.Description)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Product.Description)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Product.IsDeleted)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Product.IsDeleted)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Product.CreationDate)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Product.CreationDate)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Product.CreatorUserID)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Product.CreatorUserID)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Product.ImageUrl)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Product.ImageUrl)
</dd>
</dl>
<form method="post">
<input type="hidden" asp-for="Product.Id" />
<input type="submit" value="Delete" class="btn btn-danger" /> |
<a asp-page="./Index">Back to List</a>
</form>
</div>

View File

@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using CRM.Data;
using CRM.Models;
namespace CRM.Pages.Products
{
public class DeleteModel : PageModel
{
private readonly CRM.Data.CRMContext _context;
public DeleteModel(CRM.Data.CRMContext context)
{
_context = context;
}
[BindProperty]
public Product Product { get; set; } = default!;
public async Task<IActionResult> OnGetAsync(int? id)
{
if (id == null || _context.Product == null)
{
return NotFound();
}
var product = await _context.Product.FirstOrDefaultAsync(m => m.Id == id);
if (product == null)
{
return NotFound();
}
else
{
Product = product;
}
return Page();
}
public async Task<IActionResult> OnPostAsync(int? id)
{
if (id == null || _context.Product == null)
{
return NotFound();
}
var product = await _context.Product.FindAsync(id);
if (product != null)
{
Product = product;
_context.Product.Remove(Product);
await _context.SaveChangesAsync();
}
return RedirectToPage("./Index");
}
}
}

View File

@ -0,0 +1,55 @@
@page
@model CRM.Pages.Products.DetailsModel
@{
ViewData["Title"] = "Details";
}
<h1>Details</h1>
<div>
<h4>Product</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Product.Title)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Product.Title)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Product.Description)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Product.Description)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Product.IsDeleted)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Product.IsDeleted)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Product.CreationDate)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Product.CreationDate)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Product.CreatorUserID)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Product.CreatorUserID)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Product.ImageUrl)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Product.ImageUrl)
</dd>
</dl>
</div>
<div>
<a asp-page="./Edit" asp-route-id="@Model.Product?.Id">Edit</a> |
<a asp-page="./Index">Back to List</a>
</div>

View File

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using CRM.Data;
using CRM.Models;
namespace CRM.Pages.Products
{
public class DetailsModel : PageModel
{
private readonly CRM.Data.CRMContext _context;
public DetailsModel(CRM.Data.CRMContext context)
{
_context = context;
}
public Product Product { get; set; } = default!;
public async Task<IActionResult> OnGetAsync(int? id)
{
if (id == null || _context.Product == null)
{
return NotFound();
}
var product = await _context.Product.FirstOrDefaultAsync(m => m.Id == id);
if (product == null)
{
return NotFound();
}
else
{
Product = product;
}
return Page();
}
}
}

View File

@ -0,0 +1,60 @@
@page
@model CRM.Pages.Products.EditModel
@{
ViewData["Title"] = "Edit";
}
<h1>Edit</h1>
<h4>Product</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Product.Id" />
<div class="form-group">
<label asp-for="Product.Title" class="control-label"></label>
<input asp-for="Product.Title" class="form-control" />
<span asp-validation-for="Product.Title" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Product.Description" class="control-label"></label>
<input asp-for="Product.Description" class="form-control" />
<span asp-validation-for="Product.Description" class="text-danger"></span>
</div>
<div class="form-group form-check">
<label class="form-check-label">
<input class="form-check-input" asp-for="Product.IsDeleted" /> @Html.DisplayNameFor(model => model.Product.IsDeleted)
</label>
</div>
<div class="form-group">
<label asp-for="Product.CreationDate" class="control-label"></label>
<input asp-for="Product.CreationDate" class="form-control" />
<span asp-validation-for="Product.CreationDate" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Product.CreatorUserID" class="control-label"></label>
<input asp-for="Product.CreatorUserID" class="form-control" />
<span asp-validation-for="Product.CreatorUserID" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Product.ImageUrl" class="control-label"></label>
<input asp-for="Product.ImageUrl" class="form-control" />
<span asp-validation-for="Product.ImageUrl" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Save" class="btn btn-primary" />
</div>
</form>
</div>
</div>
<div>
<a asp-page="./Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

View File

@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using CRM.Data;
using CRM.Models;
namespace CRM.Pages.Products
{
public class EditModel : PageModel
{
private readonly CRM.Data.CRMContext _context;
public EditModel(CRM.Data.CRMContext context)
{
_context = context;
}
[BindProperty]
public Product Product { get; set; } = default!;
public async Task<IActionResult> OnGetAsync(int? id)
{
if (id == null || _context.Product == null)
{
return NotFound();
}
var product = await _context.Product.FirstOrDefaultAsync(m => m.Id == id);
if (product == null)
{
return NotFound();
}
Product = product;
return Page();
}
// To protect from overposting attacks, enable the specific properties you want to bind to.
// For more details, see https://aka.ms/RazorPagesCRUD.
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
_context.Attach(Product).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!ProductExists(Product.Id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToPage("./Index");
}
private bool ProductExists(int id)
{
return (_context.Product?.Any(e => e.Id == id)).GetValueOrDefault();
}
}
}

View File

@ -0,0 +1,66 @@
@page
@model CRM.Pages.Products.IndexModel
@{
ViewData["Title"] = "Index";
}
<h1>Index</h1>
<p>
<a asp-page="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Product[0].Title)
</th>
<th>
@Html.DisplayNameFor(model => model.Product[0].Description)
</th>
<th>
@Html.DisplayNameFor(model => model.Product[0].IsDeleted)
</th>
<th>
@Html.DisplayNameFor(model => model.Product[0].CreationDate)
</th>
<th>
@Html.DisplayNameFor(model => model.Product[0].CreatorUserID)
</th>
<th>
@Html.DisplayNameFor(model => model.Product[0].ImageUrl)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Product) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
@Html.DisplayFor(modelItem => item.IsDeleted)
</td>
<td>
@Html.DisplayFor(modelItem => item.CreationDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.CreatorUserID)
</td>
<td>
@Html.DisplayFor(modelItem => item.ImageUrl)
</td>
<td>
<a asp-page="./Edit" asp-route-id="@item.Id">Edit</a> |
<a asp-page="./Details" asp-route-id="@item.Id">Details</a> |
<a asp-page="./Delete" asp-route-id="@item.Id">Delete</a>
</td>
</tr>
}
</tbody>
</table>

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using CRM.Data;
using CRM.Models;
namespace CRM.Pages.Products
{
public class IndexModel : PageModel
{
private readonly CRM.Data.CRMContext _context;
public IndexModel(CRM.Data.CRMContext context)
{
_context = context;
}
public IList<Product> Product { get;set; } = default!;
public async Task OnGetAsync()
{
if (_context.Product != null)
{
Product = await _context.Product.ToListAsync();
}
}
}
}

View File

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - CRM</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/CRM.styles.css" asp-append-version="true" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<a class="navbar-brand" asp-area="" asp-page="/Index">CRM</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2023 - CRM - <a asp-area="" asp-page="/Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>

View File

@ -0,0 +1,48 @@
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */
a.navbar-brand {
white-space: normal;
text-align: center;
word-break: break-all;
}
a {
color: #0077cc;
}
.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.border-top {
border-top: 1px solid #e5e5e5;
}
.border-bottom {
border-bottom: 1px solid #e5e5e5;
}
.box-shadow {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}
button.accept-policy {
font-size: 1rem;
line-height: inherit;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
}

View File

@ -0,0 +1,2 @@
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>

View File

@ -0,0 +1,3 @@
@using CRM
@namespace CRM.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@ -0,0 +1,3 @@
@{
Layout = "_Layout";
}

30
CRM/Program.cs Normal file
View File

@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using CRM.Data;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddDbContext<CRMContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("CRMContext") ?? throw new InvalidOperationException("Connection string 'CRMContext' not found.")));
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.Run();

View File

@ -0,0 +1,28 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:6071",
"sslPort": 44316
}
},
"profiles": {
"CRM": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7093;http://localhost:5124",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,8 @@
{
"dependencies": {
"mssql1": {
"type": "mssql",
"connectionId": "ConnectionStrings:CRMContext"
}
}
}

View File

@ -0,0 +1,8 @@
{
"dependencies": {
"mssql1": {
"type": "mssql.local",
"connectionId": "ConnectionStrings:CRMContext"
}
}
}

View File

@ -0,0 +1,9 @@
{
"dependencies": {
"mssql1": {
"restored": true,
"restoreTime": "2023-10-23T19:27:38.4410063Z"
}
},
"parameters": {}
}

View File

@ -0,0 +1,9 @@
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

12
CRM/appsettings.json Normal file
View File

@ -0,0 +1,12 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"CRMContext": "Server=(localdb)\\mssqllocaldb;Database=CRM.Data;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,20 @@
{
"runtimeOptions": {
"tfm": "net6.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "6.0.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "6.0.0"
}
],
"configProperties": {
"System.GC.Server": true,
"System.Reflection.NullabilityInfoContext.IsSupported": true,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More