Frontend design completed

This commit is contained in:
Qais Yousuf 2024-03-30 16:10:19 +01:00
parent 366f0c7bef
commit 2ebe7ad5b3
49 changed files with 11750 additions and 12954 deletions

View file

@ -70,6 +70,18 @@ namespace Data
.HasKey(a => a.Id);
//modelBuilder.Entity<Page>()
// .HasOne(p => p.footer)
// .WithMany()
// .HasForeignKey(p => p.FooterId)
// .IsRequired(false)
// .OnDelete(DeleteBehavior.Cascade);
base.OnModelCreating(modelBuilder);
}

View file

@ -18,6 +18,11 @@ namespace Model
public string? Content { get; set; }
public int FooterId { get; set; }
[ForeignKey("FooterId")]
public Footer? footer { get; set; }
public int BannerId { get; set; }
[ForeignKey("BannerId")]

View file

@ -48,6 +48,11 @@ namespace Services.Implemnetation
return _context.Addresss.ToList();
}
public async Task<List<Address>> GetAddressesAsync()
{
return await _context.Addresss.AsNoTracking().ToListAsync();
}
public void Update(Address address)
{
_context.Addresss.Update(address);

View file

@ -47,6 +47,11 @@ namespace Services.Implemnetation
return _context.Banners.AsNoTracking().Where(x => x.Id == id).FirstOrDefault();
}
public async Task<Banner> GetBannerByIdAsync(int id)
{
return await _context.Banners.AsNoTracking().Where(x => x.Id == id).FirstOrDefaultAsync();
}
public async Task<IEnumerable<Banner>> GetBanners()
{
return await _context.Banners.AsNoTracking().ToListAsync();

View file

@ -45,11 +45,23 @@ namespace Services.Implemnetation
return _context.Pages.Where(x => x.Slug == slug).AsNoTracking().FirstOrDefault();
}
public List<Page> GetPageWithAll()
{
return _context.Pages.Include(x => x.banner).Include(x => x.footer).AsNoTracking().ToList();
}
public List<Page> GetPageWithBanner()
{
return _context.Pages.Include(x => x.banner).AsNoTracking().ToList();
}
public List<Page> GetPageWithFooter()
{
return _context.Pages.Include(x => x.footer).AsNoTracking().ToList();
}
public bool SlugExists(string slug, int? pageIdExclude = null)
{
if (pageIdExclude != null)

View file

@ -12,6 +12,8 @@ namespace Services.Interaces
List<Address> GetAddresses();
Task<List<Address>> GetAddressesAsync();
Address GetAddressById(int? id);
Task Add(Address address);

View file

@ -15,6 +15,7 @@ namespace Services.Interaces
List<Banner> GetAllBanners();
Banner GetBannerById(int id);
Task<Banner> GetBannerByIdAsync(int id);
Task Add(Banner banner);

View file

@ -19,7 +19,11 @@ namespace Services.Interaces
void Update(Page page);
List<Page> GetPageWithAll();
List<Page> GetPageWithBanner();
List<Page> GetPageWithFooter();
Page GetPageSlug(string slug);

View file

@ -11,21 +11,24 @@ namespace Web.Areas.Admin.Controllers
{
private readonly IPageRepository _pageRepository;
private readonly IBannerRepository _bannerRepository;
private readonly IFooterRepository _footerRepository;
public PageController(IPageRepository pageRepository,IBannerRepository bannerRepository)
public PageController(IPageRepository pageRepository,IBannerRepository bannerRepository, IFooterRepository footerRepository)
{
_pageRepository = pageRepository;
_bannerRepository = bannerRepository;
_footerRepository = footerRepository;
}
public IActionResult Index()
{
var pages = _pageRepository.GetPageWithBanner();
var pages = _pageRepository.GetPageWithAll();
List<PageViewModel> result = new List<PageViewModel>();
foreach (var page in pages)
{
result.Add(new PageViewModel { Id = page.Id, Title = page.Title, Slug = page.Slug, banner = page.banner });
result.Add(new PageViewModel { Id = page.Id, Title = page.Title, Slug = page.Slug, banner = page.banner,Footer=page.footer });
}
return View(result);
@ -35,6 +38,7 @@ namespace Web.Areas.Admin.Controllers
public IActionResult Create()
{
ViewBag.DropDownData=GetSidebarsForDropDownList();
ViewBag.FooterDropDown = GetFooterForDropDownList();
return View();
}
@ -48,6 +52,7 @@ namespace Web.Areas.Admin.Controllers
if(!ModelState.IsValid)
{
ViewBag.DropDownData = GetSidebarsForDropDownList();
ViewBag.FooterDropDown = GetFooterForDropDownList();
return View(viewmodel);
}
@ -64,6 +69,7 @@ namespace Web.Areas.Admin.Controllers
{
ModelState.AddModelError("", "Title or slug exists");
ViewBag.DropDownData = GetSidebarsForDropDownList();
ViewBag.FooterDropDown = GetFooterForDropDownList();
return View(viewmodel);
}
@ -74,6 +80,8 @@ namespace Web.Areas.Admin.Controllers
page.Content = viewmodel.Content;
page.banner = viewmodel.banner;
page.BannerId = viewmodel.BannerId;
page.footer = viewmodel.Footer;
page.FooterId = viewmodel.FooterId;
_pageRepository.Add(page);
@ -96,10 +104,12 @@ namespace Web.Areas.Admin.Controllers
Content=pageFromdb.Content,
banner=pageFromdb.banner,
BannerId=pageFromdb.BannerId,
Footer = pageFromdb.footer,
FooterId = pageFromdb.FooterId,
};
ViewBag.DropDownData = GetSidebarsForDropDownList();
ViewBag.FooterDropDown = GetFooterForDropDownList();
return View(viewmodel);
@ -112,6 +122,7 @@ namespace Web.Areas.Admin.Controllers
{
ViewBag.DropDownData = GetSidebarsForDropDownList();
ViewBag.FooterDropDown = GetFooterForDropDownList();
return View(viewmodel);
}
@ -128,6 +139,7 @@ namespace Web.Areas.Admin.Controllers
ModelState.AddModelError("", "Title or slug exists");
ViewBag.DropDownData = GetSidebarsForDropDownList();
ViewBag.FooterDropDown = GetFooterForDropDownList();
return View(viewmodel);
}
@ -138,6 +150,8 @@ namespace Web.Areas.Admin.Controllers
page.Content = viewmodel.Content;
page.banner = viewmodel.banner;
page.BannerId = viewmodel.BannerId;
page.footer = viewmodel.Footer;
page.FooterId = viewmodel.FooterId;
_pageRepository.Update(page);
@ -165,10 +179,13 @@ namespace Web.Areas.Admin.Controllers
Content = pageFromdb.Content,
banner = pageFromdb.banner,
BannerId = pageFromdb.BannerId,
Footer = pageFromdb.footer,
FooterId = pageFromdb.FooterId,
};
ViewBag.DropDownData = GetSidebarsForDropDownList();
ViewBag.FooterDropDown = GetFooterForDropDownList();
return View(viewmodel);
@ -202,6 +219,20 @@ namespace Web.Areas.Admin.Controllers
return dropDown;
}
private List<SelectListItem> GetFooterForDropDownList()
{
var banners = _footerRepository.GetFooter();
List<SelectListItem> dropDown = new List<SelectListItem>();
foreach (var item in banners)
{
dropDown.Add(new SelectListItem { Text = item.Title, Value = item.Id.ToString() });
}
return dropDown;
}
}
}

View file

@ -42,6 +42,11 @@
<select asp-for="BannerId" asp-items="ViewBag.DropDownData" class="form-control"></select>
<span asp-validation-for="BannerId" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="FooterId" class="control-label"></label>
<select asp-for="FooterId" asp-items=" ViewBag.FooterDropDown" class="form-control"></select>
<span asp-validation-for="FooterId" class="text-danger"></span>
</div>
<div class="mb-3">
<input type="submit" value="Create" class="btn btn-outline-primary" /> | <a asp-action="Index" class="btn btn-primary">Back to list</a>

View file

@ -35,6 +35,12 @@
<select asp-for="BannerId" asp-items="ViewBag.DropDownData" class="form-control" disabled></select>
<span asp-validation-for="BannerId" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="FooterId" class="control-label"></label>
<select asp-for="FooterId" asp-items="ViewBag.DropDownData" class="form-control" disabled></select>
<span asp-validation-for="FooterId" class="text-danger"></span>
</div>
<div class="mb-3">

View file

@ -37,6 +37,11 @@
<select asp-for="BannerId" asp-items="ViewBag.DropDownData" class="form-control"></select>
<span asp-validation-for="BannerId" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="FooterId" class="control-label"></label>
<select asp-for="FooterId" asp-items=" ViewBag.FooterDropDown" class="form-control"></select>
<span asp-validation-for="FooterId" class="text-danger"></span>
</div>
<div class="mb-3">
<input type="submit" value="Update" class="btn btn-outline-primary" /> | <a asp-action="Index" class="btn btn-primary">Back to list</a>

View file

@ -27,6 +27,7 @@
<th scope="col">Title</th>
<th scope="col">Slug</th>
<th scope="col">Banner</th>
<th scope="col">Footer</th>
<th scope="col" class="d-flex justify-content-end">Action</th>
</tr>
</thead>
@ -39,6 +40,7 @@
<td> <span class="badge bg-primary">@item.Title</span></td>
<td>@item.Slug</td>
<td>@item.banner?.Title</td>
<td>@item.Footer?.Title</td>
<td class="d-flex justify-content-end">
<a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger btn-s"><i class="bi bi-trash"></i> Delete</a> |
<a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-warning btn-s"><i class="bi bi-pencil-square"></i> Edit</a>

View file

@ -10,11 +10,13 @@
@* <h6 class="text-danger">Are you sure you want to delete this questionnaire: <span class="badge bg-danger p-2 shadow rounded">@Model.Title</span></h6> *@
<h6 class="text-danger">
Are you sure you want to delete:
<span class="badge bg-danger p-2 shadow rounded">
<span class="item-title ">@Html.Raw(Model.Title.Length >= 30 ? Model.Title.Substring(0, 30) : Model.Title)</span>
<span class="more-title " style="display:none;">@(Model.Title.Length > 30 ? Model.Title.Substring(20) : "")</span>
<span class="more-title " style="display:none;">@(Model.Title.Length > 30 ? Model.Title.Substring(30) : "")</span>
</span>
<button id="readMoreBtn" type="button" class="btn btn-link">Read More</button>
<button type="button" class="btn btn-link readMoreBtn">Read More</button>
</h6>
@ -152,19 +154,24 @@
}
});
});
});
</script>
<script>
$(document).ready(function () {
$("#readMoreBtn").click(function () {
$("#readMore").toggle();
$(".readMoreBtn").click(function () {
$(this).closest('.text-danger').find('.more-title').toggle();
$(this).text(function (_, text) {
return text === "Read More" ? "Read Less" : "Read More";
});
});
});
});
</script>
}

View file

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using Services.Interaces;
using System.Diagnostics;
using Web.Models;
@ -6,27 +7,36 @@ namespace Web.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly IPageRepository _pageRepository;
public HomeController(ILogger<HomeController> logger)
public HomeController(IPageRepository pageRepository)
{
_logger = logger;
_pageRepository = pageRepository;
}
public IActionResult Index()
public IActionResult Index(string slug)
{
return View();
if (string.IsNullOrEmpty(slug))
slug = "home";
if (!_pageRepository.SlugExists(slug))
return RedirectToAction(nameof(Error));
var pageFromdb = _pageRepository.GetPageSlug(slug);
TempData["bannerId"] = pageFromdb.BannerId;
TempData["Footer"] = pageFromdb.FooterId;
return View(pageFromdb);
}
public IActionResult Privacy()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
return View();
}
}
}

View file

@ -15,6 +15,8 @@ namespace Web.Extesions
});
}
public static void ConfigurePageServices(this IServiceCollection services)
{
services.AddScoped<IPageRepository,PageRepository>();

View file

@ -1,259 +0,0 @@
// <auto-generated />
using System;
using Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Web.Migrations
{
[DbContext(typeof(SurveyContext))]
[Migration("20240228172237_Initial")]
partial class Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Model.Address", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("CVR")
.HasColumnType("nvarchar(max)");
b.Property<string>("City")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Country")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PostalCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("State")
.HasColumnType("nvarchar(max)");
b.Property<string>("Street")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Addresss");
});
modelBuilder.Entity("Model.Banner", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ImageUrl")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("LinkUrl")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Banners");
});
modelBuilder.Entity("Model.Footer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ImageUlr")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("LastUpdated")
.HasColumnType("datetime2");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Owner")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Sitecopyright")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UpdatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Footers");
});
modelBuilder.Entity("Model.FooterSocialMedia", b =>
{
b.Property<int>("FooterId")
.HasColumnType("int");
b.Property<int>("SocialId")
.HasColumnType("int");
b.HasKey("FooterId", "SocialId");
b.HasIndex("SocialId");
b.ToTable("FooterSocialMedias");
});
modelBuilder.Entity("Model.Page", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("BannerId")
.HasColumnType("int");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Slug")
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("BannerId");
b.ToTable("Pages");
});
modelBuilder.Entity("Model.SocialMedia", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Url")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("SocialMedia");
});
modelBuilder.Entity("Model.FooterSocialMedia", b =>
{
b.HasOne("Model.Footer", "Footer")
.WithMany("FooterSocialMedias")
.HasForeignKey("FooterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Model.SocialMedia", "SocialMedia")
.WithMany("FooterSocialMedias")
.HasForeignKey("SocialId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Footer");
b.Navigation("SocialMedia");
});
modelBuilder.Entity("Model.Page", b =>
{
b.HasOne("Model.Banner", "banner")
.WithMany()
.HasForeignKey("BannerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("banner");
});
modelBuilder.Entity("Model.Footer", b =>
{
b.Navigation("FooterSocialMedias");
});
modelBuilder.Entity("Model.SocialMedia", b =>
{
b.Navigation("FooterSocialMedias");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -1,371 +0,0 @@
// <auto-generated />
using System;
using Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Web.Migrations
{
[DbContext(typeof(SurveyContext))]
[Migration("20240307153635_SurveyModelsAdded")]
partial class SurveyModelsAdded
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Model.Address", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("CVR")
.HasColumnType("nvarchar(max)");
b.Property<string>("City")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Country")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PostalCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("State")
.HasColumnType("nvarchar(max)");
b.Property<string>("Street")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Addresss");
});
modelBuilder.Entity("Model.Answer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("QuestionId")
.HasColumnType("int");
b.Property<string>("Text")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("QuestionId");
b.ToTable("Answers");
});
modelBuilder.Entity("Model.Banner", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ImageUrl")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("LinkUrl")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Banners");
});
modelBuilder.Entity("Model.Footer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ImageUlr")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("LastUpdated")
.HasColumnType("datetime2");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Owner")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Sitecopyright")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UpdatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Footers");
});
modelBuilder.Entity("Model.FooterSocialMedia", b =>
{
b.Property<int>("FooterId")
.HasColumnType("int");
b.Property<int>("SocialId")
.HasColumnType("int");
b.HasKey("FooterId", "SocialId");
b.HasIndex("SocialId");
b.ToTable("FooterSocialMedias");
});
modelBuilder.Entity("Model.Page", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("BannerId")
.HasColumnType("int");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Slug")
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("BannerId");
b.ToTable("Pages");
});
modelBuilder.Entity("Model.Question", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("QuestionnaireId")
.HasColumnType("int");
b.Property<string>("Text")
.HasColumnType("nvarchar(max)");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("QuestionnaireId");
b.ToTable("Questions");
});
modelBuilder.Entity("Model.QuestionTypeEntities", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("QuestionTypeEntities");
});
modelBuilder.Entity("Model.Questionnaire", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Questionnaires");
});
modelBuilder.Entity("Model.SocialMedia", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Url")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("SocialMedia");
});
modelBuilder.Entity("Model.Answer", b =>
{
b.HasOne("Model.Question", "Question")
.WithMany("Answers")
.HasForeignKey("QuestionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Question");
});
modelBuilder.Entity("Model.FooterSocialMedia", b =>
{
b.HasOne("Model.Footer", "Footer")
.WithMany("FooterSocialMedias")
.HasForeignKey("FooterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Model.SocialMedia", "SocialMedia")
.WithMany("FooterSocialMedias")
.HasForeignKey("SocialId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Footer");
b.Navigation("SocialMedia");
});
modelBuilder.Entity("Model.Page", b =>
{
b.HasOne("Model.Banner", "banner")
.WithMany()
.HasForeignKey("BannerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("banner");
});
modelBuilder.Entity("Model.Question", b =>
{
b.HasOne("Model.Questionnaire", "Questionnaire")
.WithMany("Questions")
.HasForeignKey("QuestionnaireId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Questionnaire");
});
modelBuilder.Entity("Model.Footer", b =>
{
b.Navigation("FooterSocialMedias");
});
modelBuilder.Entity("Model.Question", b =>
{
b.Navigation("Answers");
});
modelBuilder.Entity("Model.Questionnaire", b =>
{
b.Navigation("Questions");
});
modelBuilder.Entity("Model.SocialMedia", b =>
{
b.Navigation("FooterSocialMedias");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -1,108 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Web.Migrations
{
/// <inheritdoc />
public partial class SurveyModelsAdded : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Questionnaires",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(max)", nullable: true),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Questionnaires", x => x.Id);
});
migrationBuilder.CreateTable(
name: "QuestionTypeEntities",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Type = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_QuestionTypeEntities", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Questions",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Text = table.Column<string>(type: "nvarchar(max)", nullable: true),
Type = table.Column<int>(type: "int", nullable: false),
QuestionnaireId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Questions", x => x.Id);
table.ForeignKey(
name: "FK_Questions_Questionnaires_QuestionnaireId",
column: x => x.QuestionnaireId,
principalTable: "Questionnaires",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Answers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Text = table.Column<string>(type: "nvarchar(max)", nullable: true),
QuestionId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Answers", x => x.Id);
table.ForeignKey(
name: "FK_Answers_Questions_QuestionId",
column: x => x.QuestionId,
principalTable: "Questions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Answers_QuestionId",
table: "Answers",
column: "QuestionId");
migrationBuilder.CreateIndex(
name: "IX_Questions_QuestionnaireId",
table: "Questions",
column: "QuestionnaireId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Answers");
migrationBuilder.DropTable(
name: "QuestionTypeEntities");
migrationBuilder.DropTable(
name: "Questions");
migrationBuilder.DropTable(
name: "Questionnaires");
}
}
}

View file

@ -1,371 +0,0 @@
// <auto-generated />
using System;
using Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Web.Migrations
{
[DbContext(typeof(SurveyContext))]
[Migration("20240308144608_DifferntTypeofQuestionAdded")]
partial class DifferntTypeofQuestionAdded
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Model.Address", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("CVR")
.HasColumnType("nvarchar(max)");
b.Property<string>("City")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Country")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PostalCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("State")
.HasColumnType("nvarchar(max)");
b.Property<string>("Street")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Addresss");
});
modelBuilder.Entity("Model.Answer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("QuestionId")
.HasColumnType("int");
b.Property<string>("Text")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("QuestionId");
b.ToTable("Answers");
});
modelBuilder.Entity("Model.Banner", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ImageUrl")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("LinkUrl")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Banners");
});
modelBuilder.Entity("Model.Footer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ImageUlr")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("LastUpdated")
.HasColumnType("datetime2");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Owner")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Sitecopyright")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UpdatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Footers");
});
modelBuilder.Entity("Model.FooterSocialMedia", b =>
{
b.Property<int>("FooterId")
.HasColumnType("int");
b.Property<int>("SocialId")
.HasColumnType("int");
b.HasKey("FooterId", "SocialId");
b.HasIndex("SocialId");
b.ToTable("FooterSocialMedias");
});
modelBuilder.Entity("Model.Page", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("BannerId")
.HasColumnType("int");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Slug")
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("BannerId");
b.ToTable("Pages");
});
modelBuilder.Entity("Model.Question", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("QuestionnaireId")
.HasColumnType("int");
b.Property<string>("Text")
.HasColumnType("nvarchar(max)");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("QuestionnaireId");
b.ToTable("Questions");
});
modelBuilder.Entity("Model.QuestionTypeEntities", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("QuestionTypeEntities");
});
modelBuilder.Entity("Model.Questionnaire", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Questionnaires");
});
modelBuilder.Entity("Model.SocialMedia", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Url")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("SocialMedia");
});
modelBuilder.Entity("Model.Answer", b =>
{
b.HasOne("Model.Question", "Question")
.WithMany("Answers")
.HasForeignKey("QuestionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Question");
});
modelBuilder.Entity("Model.FooterSocialMedia", b =>
{
b.HasOne("Model.Footer", "Footer")
.WithMany("FooterSocialMedias")
.HasForeignKey("FooterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Model.SocialMedia", "SocialMedia")
.WithMany("FooterSocialMedias")
.HasForeignKey("SocialId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Footer");
b.Navigation("SocialMedia");
});
modelBuilder.Entity("Model.Page", b =>
{
b.HasOne("Model.Banner", "banner")
.WithMany()
.HasForeignKey("BannerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("banner");
});
modelBuilder.Entity("Model.Question", b =>
{
b.HasOne("Model.Questionnaire", "Questionnaire")
.WithMany("Questions")
.HasForeignKey("QuestionnaireId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Questionnaire");
});
modelBuilder.Entity("Model.Footer", b =>
{
b.Navigation("FooterSocialMedias");
});
modelBuilder.Entity("Model.Question", b =>
{
b.Navigation("Answers");
});
modelBuilder.Entity("Model.Questionnaire", b =>
{
b.Navigation("Questions");
});
modelBuilder.Entity("Model.SocialMedia", b =>
{
b.Navigation("FooterSocialMedias");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -1,22 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Web.Migrations
{
/// <inheritdoc />
public partial class DifferntTypeofQuestionAdded : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View file

@ -1,355 +0,0 @@
// <auto-generated />
using System;
using Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Web.Migrations
{
[DbContext(typeof(SurveyContext))]
[Migration("20240323171512_QuestionTypeEntityRemoved")]
partial class QuestionTypeEntityRemoved
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Model.Address", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("CVR")
.HasColumnType("nvarchar(max)");
b.Property<string>("City")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Country")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PostalCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("State")
.HasColumnType("nvarchar(max)");
b.Property<string>("Street")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Addresss");
});
modelBuilder.Entity("Model.Answer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("QuestionId")
.HasColumnType("int");
b.Property<string>("Text")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("QuestionId");
b.ToTable("Answers");
});
modelBuilder.Entity("Model.Banner", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ImageUrl")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("LinkUrl")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Banners");
});
modelBuilder.Entity("Model.Footer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ImageUlr")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("LastUpdated")
.HasColumnType("datetime2");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Owner")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Sitecopyright")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UpdatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Footers");
});
modelBuilder.Entity("Model.FooterSocialMedia", b =>
{
b.Property<int>("FooterId")
.HasColumnType("int");
b.Property<int>("SocialId")
.HasColumnType("int");
b.HasKey("FooterId", "SocialId");
b.HasIndex("SocialId");
b.ToTable("FooterSocialMedias");
});
modelBuilder.Entity("Model.Page", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("BannerId")
.HasColumnType("int");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Slug")
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("BannerId");
b.ToTable("Pages");
});
modelBuilder.Entity("Model.Question", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("QuestionnaireId")
.HasColumnType("int");
b.Property<string>("Text")
.HasColumnType("nvarchar(max)");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("QuestionnaireId");
b.ToTable("Questions");
});
modelBuilder.Entity("Model.Questionnaire", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Questionnaires");
});
modelBuilder.Entity("Model.SocialMedia", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Url")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("SocialMedia");
});
modelBuilder.Entity("Model.Answer", b =>
{
b.HasOne("Model.Question", "Question")
.WithMany("Answers")
.HasForeignKey("QuestionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Question");
});
modelBuilder.Entity("Model.FooterSocialMedia", b =>
{
b.HasOne("Model.Footer", "Footer")
.WithMany("FooterSocialMedias")
.HasForeignKey("FooterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Model.SocialMedia", "SocialMedia")
.WithMany("FooterSocialMedias")
.HasForeignKey("SocialId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Footer");
b.Navigation("SocialMedia");
});
modelBuilder.Entity("Model.Page", b =>
{
b.HasOne("Model.Banner", "banner")
.WithMany()
.HasForeignKey("BannerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("banner");
});
modelBuilder.Entity("Model.Question", b =>
{
b.HasOne("Model.Questionnaire", "Questionnaire")
.WithMany("Questions")
.HasForeignKey("QuestionnaireId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Questionnaire");
});
modelBuilder.Entity("Model.Footer", b =>
{
b.Navigation("FooterSocialMedias");
});
modelBuilder.Entity("Model.Question", b =>
{
b.Navigation("Answers");
});
modelBuilder.Entity("Model.Questionnaire", b =>
{
b.Navigation("Questions");
});
modelBuilder.Entity("Model.SocialMedia", b =>
{
b.Navigation("FooterSocialMedias");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -1,34 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Web.Migrations
{
/// <inheritdoc />
public partial class QuestionTypeEntityRemoved : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "QuestionTypeEntities");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "QuestionTypeEntities",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Type = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_QuestionTypeEntities", x => x.Id);
});
}
}
}

View file

@ -1,54 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Web.Migrations
{
/// <inheritdoc />
public partial class QeustionAndAnswerNameAdded : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Text",
table: "Questions",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Text",
table: "Answers",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Text",
table: "Questions",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<string>(
name: "Text",
table: "Answers",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
}
}
}

View file

@ -1,355 +0,0 @@
// <auto-generated />
using System;
using Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Web.Migrations
{
[DbContext(typeof(SurveyContext))]
[Migration("20240326164756_requiredRevmoedFromQuestionAndAnswer")]
partial class requiredRevmoedFromQuestionAndAnswer
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Model.Address", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("CVR")
.HasColumnType("nvarchar(max)");
b.Property<string>("City")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Country")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PostalCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("State")
.HasColumnType("nvarchar(max)");
b.Property<string>("Street")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Addresss");
});
modelBuilder.Entity("Model.Answer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("QuestionId")
.HasColumnType("int");
b.Property<string>("Text")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("QuestionId");
b.ToTable("Answers");
});
modelBuilder.Entity("Model.Banner", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ImageUrl")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("LinkUrl")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Banners");
});
modelBuilder.Entity("Model.Footer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ImageUlr")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("LastUpdated")
.HasColumnType("datetime2");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Owner")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Sitecopyright")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UpdatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Footers");
});
modelBuilder.Entity("Model.FooterSocialMedia", b =>
{
b.Property<int>("FooterId")
.HasColumnType("int");
b.Property<int>("SocialId")
.HasColumnType("int");
b.HasKey("FooterId", "SocialId");
b.HasIndex("SocialId");
b.ToTable("FooterSocialMedias");
});
modelBuilder.Entity("Model.Page", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("BannerId")
.HasColumnType("int");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Slug")
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("BannerId");
b.ToTable("Pages");
});
modelBuilder.Entity("Model.Question", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("QuestionnaireId")
.HasColumnType("int");
b.Property<string>("Text")
.HasColumnType("nvarchar(max)");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("QuestionnaireId");
b.ToTable("Questions");
});
modelBuilder.Entity("Model.Questionnaire", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Questionnaires");
});
modelBuilder.Entity("Model.SocialMedia", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Url")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("SocialMedia");
});
modelBuilder.Entity("Model.Answer", b =>
{
b.HasOne("Model.Question", "Question")
.WithMany("Answers")
.HasForeignKey("QuestionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Question");
});
modelBuilder.Entity("Model.FooterSocialMedia", b =>
{
b.HasOne("Model.Footer", "Footer")
.WithMany("FooterSocialMedias")
.HasForeignKey("FooterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Model.SocialMedia", "SocialMedia")
.WithMany("FooterSocialMedias")
.HasForeignKey("SocialId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Footer");
b.Navigation("SocialMedia");
});
modelBuilder.Entity("Model.Page", b =>
{
b.HasOne("Model.Banner", "banner")
.WithMany()
.HasForeignKey("BannerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("banner");
});
modelBuilder.Entity("Model.Question", b =>
{
b.HasOne("Model.Questionnaire", "Questionnaire")
.WithMany("Questions")
.HasForeignKey("QuestionnaireId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Questionnaire");
});
modelBuilder.Entity("Model.Footer", b =>
{
b.Navigation("FooterSocialMedias");
});
modelBuilder.Entity("Model.Question", b =>
{
b.Navigation("Answers");
});
modelBuilder.Entity("Model.Questionnaire", b =>
{
b.Navigation("Questions");
});
modelBuilder.Entity("Model.SocialMedia", b =>
{
b.Navigation("FooterSocialMedias");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -1,54 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Web.Migrations
{
/// <inheritdoc />
public partial class requiredRevmoedFromQuestionAndAnswer : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Text",
table: "Questions",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<string>(
name: "Text",
table: "Answers",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Text",
table: "Questions",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Text",
table: "Answers",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
}
}
}

View file

@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Web.Migrations
{
[DbContext(typeof(SurveyContext))]
[Migration("20240326164015_QeustionAndAnswerNameAdded")]
partial class QeustionAndAnswerNameAdded
[Migration("20240327153248_DataBaseCreated")]
partial class DataBaseCreated
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -80,7 +80,6 @@ namespace Web.Migrations
.HasColumnType("int");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
@ -201,6 +200,9 @@ namespace Web.Migrations
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("FooterId")
.HasColumnType("int");
b.Property<string>("Slug")
.HasColumnType("nvarchar(max)");
@ -212,6 +214,8 @@ namespace Web.Migrations
b.HasIndex("BannerId");
b.HasIndex("FooterId");
b.ToTable("Pages");
});
@ -227,7 +231,6 @@ namespace Web.Migrations
.HasColumnType("int");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Type")
@ -318,7 +321,15 @@ namespace Web.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Model.Footer", "footer")
.WithMany()
.HasForeignKey("FooterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("banner");
b.Navigation("footer");
});
modelBuilder.Entity("Model.Question", b =>

View file

@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace Web.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration
public partial class DataBaseCreated : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
@ -69,6 +69,20 @@ namespace Web.Migrations
table.PrimaryKey("PK_Footers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Questionnaires",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(max)", nullable: true),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Questionnaires", x => x.Id);
});
migrationBuilder.CreateTable(
name: "SocialMedia",
columns: table => new
@ -92,6 +106,7 @@ namespace Web.Migrations
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
Slug = table.Column<string>(type: "nvarchar(max)", nullable: true),
Content = table.Column<string>(type: "nvarchar(max)", nullable: false),
FooterId = table.Column<int>(type: "int", nullable: false),
BannerId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
@ -103,6 +118,33 @@ namespace Web.Migrations
principalTable: "Banners",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Pages_Footers_FooterId",
column: x => x.FooterId,
principalTable: "Footers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Questions",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Text = table.Column<string>(type: "nvarchar(max)", nullable: true),
Type = table.Column<int>(type: "int", nullable: false),
QuestionnaireId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Questions", x => x.Id);
table.ForeignKey(
name: "FK_Questions_Questionnaires_QuestionnaireId",
column: x => x.QuestionnaireId,
principalTable: "Questionnaires",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
@ -129,6 +171,31 @@ namespace Web.Migrations
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Answers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Text = table.Column<string>(type: "nvarchar(max)", nullable: true),
QuestionId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Answers", x => x.Id);
table.ForeignKey(
name: "FK_Answers_Questions_QuestionId",
column: x => x.QuestionId,
principalTable: "Questions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Answers_QuestionId",
table: "Answers",
column: "QuestionId");
migrationBuilder.CreateIndex(
name: "IX_FooterSocialMedias_SocialId",
table: "FooterSocialMedias",
@ -138,6 +205,16 @@ namespace Web.Migrations
name: "IX_Pages_BannerId",
table: "Pages",
column: "BannerId");
migrationBuilder.CreateIndex(
name: "IX_Pages_FooterId",
table: "Pages",
column: "FooterId");
migrationBuilder.CreateIndex(
name: "IX_Questions_QuestionnaireId",
table: "Questions",
column: "QuestionnaireId");
}
/// <inheritdoc />
@ -146,6 +223,9 @@ namespace Web.Migrations
migrationBuilder.DropTable(
name: "Addresss");
migrationBuilder.DropTable(
name: "Answers");
migrationBuilder.DropTable(
name: "FooterSocialMedias");
@ -153,13 +233,19 @@ namespace Web.Migrations
name: "Pages");
migrationBuilder.DropTable(
name: "Footers");
name: "Questions");
migrationBuilder.DropTable(
name: "SocialMedia");
migrationBuilder.DropTable(
name: "Banners");
migrationBuilder.DropTable(
name: "Footers");
migrationBuilder.DropTable(
name: "Questionnaires");
}
}
}

View file

@ -197,6 +197,9 @@ namespace Web.Migrations
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("FooterId")
.HasColumnType("int");
b.Property<string>("Slug")
.HasColumnType("nvarchar(max)");
@ -208,6 +211,8 @@ namespace Web.Migrations
b.HasIndex("BannerId");
b.HasIndex("FooterId");
b.ToTable("Pages");
});
@ -313,7 +318,15 @@ namespace Web.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Model.Footer", "footer")
.WithMany()
.HasForeignKey("FooterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("banner");
b.Navigation("footer");
});
modelBuilder.Entity("Model.Question", b =>

View file

@ -5,6 +5,7 @@ using Microsoft.Extensions.DependencyInjection;
using Services.Implemnetation;
using Services.Interaces;
using Web.Extesions;
using Web.ViewComponents;
var builder = WebApplication.CreateBuilder(args);
@ -20,7 +21,7 @@ builder.Services.AddDbContext<SurveyContext>(options =>
});
//builder.Services.ConfigureSQLConnection(builder.Configuration);
builder.Services.ConfigurePageServices();
builder.Services.ConfigureBannerServices();
@ -30,6 +31,7 @@ builder.Services.ConfigureFooter();
builder.Services.ConfigureQuestionnarie();
builder.Services.ConfigureQuestion();
builder.Services.AddScoped<SurveyContext>();
builder.Services.AddTransient<NavigationViewComponent>();
var app = builder.Build();
@ -49,6 +51,11 @@ app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "page",
pattern: "{slug}", defaults: new { Controller = "Home", Action = "Index" });
app.MapAreaControllerRoute(
name: "MyAdminArea",
areaName:"admin",

View file

@ -0,0 +1,24 @@
using Microsoft.AspNetCore.Mvc;
using Services.Implemnetation;
using Services.Interaces;
namespace Web.ViewComponents
{
public class AddressViewComponent:ViewComponent
{
private readonly IAddressRepository _addressRepository;
public AddressViewComponent(IAddressRepository addressRepository)
{
_addressRepository = addressRepository;
}
public async Task<IViewComponentResult> InvokeAsync()
{
var address = await _addressRepository.GetAddressesAsync();
return View(address);
}
}
}

View file

@ -0,0 +1,25 @@
using Microsoft.AspNetCore.Mvc;
using Services.Interaces;
namespace Web.ViewComponents
{
public class BannerViewComponent:ViewComponent
{
private readonly IBannerRepository _bannerRepository;
public BannerViewComponent(IBannerRepository bannerRepository)
{
_bannerRepository = bannerRepository;
}
public async Task<IViewComponentResult> InvokeAsync()
{
int bannerId = (int)TempData["bannerId"];
var Banner = await _bannerRepository.GetBannerByIdAsync(bannerId);
return View(Banner);
}
}
}

View file

@ -0,0 +1,52 @@
using Microsoft.AspNetCore.Mvc;
using Services.Implemnetation;
using Services.Interaces;
namespace Web.ViewComponents
{
public class FooterViewComponent:ViewComponent
{
private readonly IFooterRepository _footerRepository;
public FooterViewComponent(IFooterRepository footerRepository)
{
_footerRepository = footerRepository;
}
public IViewComponentResult Invoke()
{
if (!TempData.ContainsKey("Footer"))
{
// Handle the case where "Footer" is not found in TempData
// For example, return a default view or perform a different action
return View("DefaultFooterView"); // Return a default view named "DefaultFooterView"
}
if (!int.TryParse(TempData["Footer"].ToString(), out int footerId))
{
// Handle the case where "Footer" value is not a valid integer
// For example, return a default view or perform a different action
return View("DefaultFooterView"); // Return a default view named "DefaultFooterView"
}
var footer = _footerRepository.GetFooterByIdWithSocialMedia(footerId);
if (footer == null)
{
// Handle the case where the footer is not found
// For example, return a default view or perform a different action
return View("DefaultFooterView"); // Return a default view named "DefaultFooterView"
}
return View(footer);
}
//public IViewComponentResult Invoke()
//{
// int footerId = (int)TempData["bannerId"];
// var footer = _footerRepository.GetFooterById(footerId);
// return View(footer);
//}
}
}

View file

@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Mvc;
using Services.Interaces;
namespace Web.ViewComponents
{
public class NavigationFooterViewComponent:ViewComponent
{
private readonly IPageRepository _pageRepository;
public NavigationFooterViewComponent(IPageRepository pageRepository)
{
_pageRepository = pageRepository;
}
public async Task<IViewComponentResult> InvokeAsync()
{
var pages = await _pageRepository.GetPages();
return View(pages);
}
}
}

View file

@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Mvc;
using Services.Interaces;
namespace Web.ViewComponents
{
public class NavigationViewComponent:ViewComponent
{
private readonly IPageRepository _pageRepository;
public NavigationViewComponent(IPageRepository pageRepository)
{
_pageRepository = pageRepository;
}
public async Task<IViewComponentResult> InvokeAsync()
{
var pages = await _pageRepository.GetPages();
return View(pages);
}
}
}

View file

@ -15,6 +15,13 @@ namespace Web.ViewModel.PageVM
public string? Content { get; set; }
[DisplayName("Footer")]
public int FooterId { get; set; }
[ForeignKey("FooterId")]
public Footer? Footer { get; set; }
[DisplayName("Banner")]
public int BannerId { get; set; }

View file

@ -13,7 +13,7 @@ namespace Web.ViewModel.QuestionnaireVM
[Required]
[Display(Name ="Questionnaire title")]
[StringLength(100, ErrorMessage = "Title must be between 1 and 40 characters.", MinimumLength = 1)]
[StringLength(40, ErrorMessage = "Title must be between 1 and 40 characters.", MinimumLength = 1)]
public string? Title { get; set; }
[Required]
public string? Description { get; set; }

View file

@ -15,7 +15,7 @@ namespace Web.ViewModel.QuestionnaireVM
}
public int Id { get; set; }
[Required]
[StringLength(100, ErrorMessage = "Title must be between 1 and 40 characters.", MinimumLength = 1)]
[StringLength(40, ErrorMessage = "Title must be between 1 and 40 characters.", MinimumLength = 1)]
public string? Title { get; set; }
[Required]
public string? Description { get; set; }

View file

@ -0,0 +1,6 @@
@{
ViewData["Title"] = "Home Page";
}
<h1>Error</h1>
<p class="alert alert-danger">Something went wrong.....</p>

View file

@ -1,42 +1,35 @@
@{
@model Page
@{
ViewData["Title"] = "Home Page";
}
<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
<ol class="carousel-indicators">
<li data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active"></li>
<li data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1"></li>
<li data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://mdbootstrap.com/img/Photos/Slides/img%20(45).jpg"
class="d-block w-100"
alt="first slide" />
<!-- FOR DEMO PURPOSE -->
<section id="MainContent" class="hero text-white">
<div class="container py-1">
@* <div class="col-12" id="boxBanner">
<h1 class="display-6 text-white font-weight-bold">@Model.Description.ToUpper()</h1>
</div> *@
<div id="rowSectionMain">
<div class="col-lg-12" id="boxMain">
<div class="display-6 font-weight-bold text-white">@Model.Title.ToUpper()</div>
@* <p class="fst-italic text-muted">@Html.Raw(Model.Content) <a class="text-primary" href="@Model.Sitecopyright" target="_blank">SeoSoft</a></p> *@
<p class="text-white">@Html.Raw(Model.Content)</p>
<a href="#" class="btn mt-1" id="HomeButon"> Contact <i class="bi bi-ui-checks"></i></a>
</div>
<div class="carousel-item">
<img src="https://mdbootstrap.com/img/Photos/Slides/img%20(46).jpg"
class="d-block w-100"
alt="second slide" />
</div>
<div class="carousel-item">
<img src="https://mdbootstrap.com/img/Photos/Slides/img%20(47).jpg"
class="d-block w-100"
alt="third slide" />
</div>
</div>
<a class="carousel-control-prev"
href="#carouselExampleIndicators"
role="button"
data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next"
href="#carouselExampleIndicators"
role="button"
data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</section>

View file

@ -0,0 +1,40 @@
@model List<Address>
<div class="col-lg-2 col-md-6">
<h5 class="text-white mb-3">Address</h5>
@foreach (var item in Model.Take(1))
{
<p class="line-spacing text-white text-muted">
<strong>Street:</strong> @item.Street <br>
<strong>City:</strong> @item.City <br>
<strong>State:</strong> @item.State <br>
<strong>Postal Code:</strong> @item.PostalCode <br>
<strong>Country:</strong> @item.Country <br>
</p>
}
</div>
<div class="col-lg-2 col-md-6">
<h5 class="text-white mb-3">Contact</h5>
@foreach (var item in Model.Take(1))
{
<p class="line-spacing text-white text-muted">
<strong>Email:</strong> <a id="LinkColor" href="mailto:@item.Email">@item.Email</a> <br>
<strong>Mobile:</strong> <a id="LinkColor" href="tel:@item.Mobile">@item.Mobile</a> <br>
<strong>CVR:</strong> @item.CVR <br>
</p>
}
</div>

View file

@ -0,0 +1,31 @@
@model Banner
<div class="d-flex flex-column" id="BannerBackground">
<!-- FOR DEMO PURPOSE -->
<section class="hero text-white">
<div class="container py-1">
@* <div class="col-12" id="boxBanner">
<h1 class="display-6 text-white font-weight-bold">@Model.Description.ToUpper()</h1>
</div> *@
<div id="rowSectionBanner">
<div class="col-lg-6" id="boxBanner">
<h1 class="display-6 font-weight-bold" id="BtnColor">@Model.Title.ToUpper()</h1>
<h6 class="text-white font-weight-bold">@Model.Description.ToUpper()</h6>
@* <p class="fst-italic text-muted">@Html.Raw(Model.Content) <a class="text-primary" href="@Model.Sitecopyright" target="_blank">SeoSoft</a></p> *@
<p class="text-white">@Html.Raw(Model.Content)</p>
<a href="@Model.LinkUrl" class="btn mt-1" id="BannerButon"> Contact <i class="bi bi-ui-checks"></i></a>
</div>
<div class="col-lg-6" id="boxBanner">
<script src="https://unpkg.com/@@dotlottie/player-component@latest/dist/dotlottie-player.mjs" type="module"></script>
<dotlottie-player src="@Model.ImageUrl" class="img-fluid" speed="1" style="width: auto; height: auto;" direction="1" playMode="normal" loop autoplay></dotlottie-player>
</div>
</div>
</div>
</section>
</div>

View file

@ -0,0 +1,94 @@
@model Footer
<div class="d-flex flex-column" id="Background">
<!-- FOR DEMO PURPOSE -->
<section class="hero text-white flex-grow-1">
<div class="container py-4">
<div id="rowSection">
<div class="col-lg-6" id="box">
<h1 class="display-6 text-white font-weight-bold">@Model.Title.ToUpper()</h1>
@* <p class="fst-italic text-muted">@Html.Raw(Model.Content) <a class="text-primary" href="@Model.Sitecopyright" target="_blank">SeoSoft</a></p> *@
but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="col-lg-6" id="box">
<script src="https://unpkg.com/@@dotlottie/player-component@latest/dist/dotlottie-player.mjs" type="module"></script>
<dotlottie-player src="https://lottie.host/f2df0cd6-fbde-4071-ab90-d9e74a075d5a/ygq5zJ9mzx.json" class="img-fluid" speed="1" style="width: auto; height: auto;" direction="1" playMode="normal" loop autoplay></dotlottie-player>
</div>
</div>
</div>
</section>
<!-- FOOTER -->
<footer class="w-100 py-4 flex-shrink-0">
<div class="container py-4">
<div class="row justify-content-around">
<vc:address></vc:address>
<div class="col-lg-2 col-md-6">
<vc:navigation-footer></vc:navigation-footer>
</div>
<div class="col-lg-4 col-md-6">
<h5 class="text-white mb-3">Newsletter</h5>
<form action="#">
<div class="input-group mb-3">
<input class="form-control" type="text" placeholder="Recipient's username" aria-label="Email" aria-describedby="button-addon2">
<button class="btn" id="BannerButon" type="button">Subscribe</button>
</div>
</form>
<ul class="list-unstyled text-muted">
@foreach (var footerSocialMedia in Model.FooterSocialMedias)
{
<li class="nav-item">
<a id="LinkColor" href="@footerSocialMedia.SocialMedia.Url" target="_blank">@footerSocialMedia.SocialMedia.Name</a>
</li>
}
</ul>
</div>
</div>
</div>
<div class="container">
<hr class="border border-primary border-start-0 border-1 opacity-35">
<div class="row d-flex justify-content-around">
<div class="col-lg-2 col-md-3">
<span class=" muted">Designed by @Model.CreatedBy</span>
</div>
<div class="col-lg-2 col-md-3">
<span class=" muted">Update by @Model.UpdatedBy</span>
</div>
<div class="col-lg-2 col-md-3">
<span class=" muted">Updated @Model.LastUpdated.ToShortDateString()</span>
</div>
<div class="col-lg-2 col-md-3">
<span class=" muted">Owner @Model.Owner</span>
</div>
</div>
</div>
</footer>
</div>

View file

@ -0,0 +1,10 @@
@model List<Page>
@foreach (var item in Model)
{
<li class="nav-item">
<a class="nav-link font-weight-normal" asp-controller="Home" asp-action="Index" asp-route-slug="@item.Slug">@item.Title</a>
</li>
}

View file

@ -0,0 +1,17 @@
@model List<Page>
<h5 class="text-white">Navigation</h5>
<ul class="list-unstyled text-muted">
@foreach (var item in Model)
{
<li class="nav-item">
<a id="LinkColor" asp-controller="Home" asp-action="Index" asp-route-slug="@item.Slug">@item.Title</a>
</li>
}
</ul>

View file

@ -10,40 +10,43 @@
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light shadow-lg">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Web</a>
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Online survey</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>
<span class="navbar-toggler-icon text-white"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<vc:navigation></vc:navigation>
</ul>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Admin" asp-controller="Admin" asp-action="Index">Admin</a>
<a href="#" class="btn btn-sm " id="BannerButon"> Sign in <i class="bi bi-ui-checks"></i></a> |
<a href="#" class="btn btn-sm" id="BannerButon"> Sign up <i class="bi bi-ui-checks"></i></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; 2024 - Web - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<main role="main">
<vc:banner></vc:banner>
@RenderBody()
</main>
<vc:footer></vc: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>

View file

@ -1,3 +1,5 @@
@using Web
@using Model
@using Web.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *,Web

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
@ -13,6 +13,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -26,4 +27,8 @@
<ProjectReference Include="..\Services\Services.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\Images\" />
</ItemGroup>
</Project>

File diff suppressed because it is too large Load diff