config footer

This commit is contained in:
Qais Yousuf 2024-03-03 13:57:57 +01:00
parent 3b98fd109f
commit 3a8f1405b5
48 changed files with 13701 additions and 160 deletions

View file

@ -21,6 +21,33 @@ namespace Data
public DbSet<Address> Addresss { get; set; } public DbSet<Address> Addresss { get; set; }
public DbSet<Footer> Footers { get; set; } public DbSet<Footer> Footers { get; set; }
public DbSet<SocialMedia> SocialMedia { get; set; }
public DbSet<FooterSocialMedia> FooterSocialMedias { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<FooterSocialMedia>()
.HasKey(fsm => new { fsm.FooterId, fsm.SocialId });
modelBuilder.Entity<FooterSocialMedia>()
.HasOne(fsm => fsm.Footer)
.WithMany(f => f.FooterSocialMedias)
.HasForeignKey(fsm => fsm.FooterId);
modelBuilder.Entity<FooterSocialMedia>()
.HasOne(fsm => fsm.SocialMedia)
.WithMany(s => s.FooterSocialMedias)
.HasForeignKey(fsm => fsm.SocialId);
base.OnModelCreating(modelBuilder);
}
} }
} }

View file

@ -29,5 +29,8 @@ namespace Model
public string? Sitecopyright { get; set;} public string? Sitecopyright { get; set;}
public List<FooterSocialMedia>? FooterSocialMedias { get; set; }
} }
} }

View file

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class FooterSocialMedia
{
public int FooterId { get; set; }
[ForeignKey("FooterId")]
public Footer? Footer { get; set; }
public int SocialId { get; set; }
[ForeignKey("SocialId")]
public SocialMedia? SocialMedia { get; set; }
}
}

27
Model/SocialMedia.cs Normal file
View file

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class SocialMedia
{
public int Id { get; set; }
[Required]
public string? Name { get; set; }
[Required]
[DataType(DataType.Url)]
public string? Url { get; set; }
public List<FooterSocialMedia>? FooterSocialMedias { get; set; }
}
}

View file

@ -0,0 +1,56 @@
using Data;
using Microsoft.EntityFrameworkCore;
using Model;
using Services.Interaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services.Implemnetation
{
public class AddressRepository : IAddressRepository
{
private readonly SurveyContext _context;
public AddressRepository(SurveyContext context)
{
_context = context;
}
public async Task Add(Address address)
{
await _context.Addresss.AddAsync(address);
}
public async Task commitAsync()
{
await _context.SaveChangesAsync();
}
public void Delete(int id)
{
var addresId = GetAddressById(id);
_context.Addresss.Remove(addresId);
}
public Address GetAddressById(int id)
{
return _context.Addresss.AsNoTracking().Where(x => x.Id == id).FirstOrDefault();
}
public List<Address> GetAddresses()
{
return _context.Addresss.ToList();
}
public void Update(Address address)
{
_context.Addresss.Update(address);
}
}
}

View file

@ -0,0 +1,60 @@
using Data;
using Microsoft.EntityFrameworkCore;
using Model;
using Services.Interaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services.Implemnetation
{
public class FooterRepository:IFooterRepository
{
private readonly SurveyContext _context;
public FooterRepository(SurveyContext Context)
{
_context = Context;
}
public async Task Add(Footer footer)
{
await _context.Footers.AddAsync(footer);
}
public async Task commitAsync()
{
await _context.SaveChangesAsync();
}
public void Delete(int id)
{
var footerWithId=GetFooterById(id);
_context.Footers.Remove(footerWithId);
}
public List<Footer> GetFooter()
{
return _context.Footers.AsNoTracking().Include(x=>x.FooterSocialMedias).ThenInclude(x=>x.SocialMedia).ToList();
}
public Footer GetFooterById(int id)
{
return _context.Footers.AsNoTracking().Include(y => y.FooterSocialMedias).Where(x => x.Id == id).FirstOrDefault();
}
public void Update(Footer footer)
{
_context.Footers.Update(footer);
}
public List<Footer> GetFooterWithFooterSocial()
{
return _context.Footers.AsNoTracking().Include(x => x.FooterSocialMedias).ThenInclude(x => x.SocialMedia).ToList();
}
}
}

View file

@ -0,0 +1,61 @@
using Data;
using Microsoft.EntityFrameworkCore;
using Model;
using Services.Interaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services.Implemnetation
{
public class SocialMediaRepository:ISocialMediaRepository
{
private readonly SurveyContext _context;
public SocialMediaRepository(SurveyContext Context)
{
_context = Context;
}
public async Task Add(SocialMedia socialMedia)
{
await _context.SocialMedia.AddAsync(socialMedia);
}
public async Task commitAsync()
{
await _context.SaveChangesAsync();
}
public void Delete(int id)
{
var socialmedia=GetSocialById(id);
_context.SocialMedia.Remove(socialmedia);
}
public List<SocialMedia> GetListofSocialMediaById(List<int> ids)
{
return ids.Select(id => GetSocialById(id)).ToList();
}
public SocialMedia GetSocialById(int id)
{
return _context.SocialMedia.AsNoTracking().Where(x => x.Id == id).FirstOrDefault();
}
public List<SocialMedia> GetSocialMedia()
{
return _context.SocialMedia.ToList();
}
public void Update(SocialMedia socialMedia)
{
_context.SocialMedia.Update(socialMedia);
}
}
}

View file

@ -0,0 +1,25 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services.Interaces
{
public interface IAddressRepository
{
List<Address> GetAddresses();
Address GetAddressById(int id);
Task Add(Address address);
void Delete(int id);
void Update(Address address);
Task commitAsync();
}
}

View file

@ -0,0 +1,26 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services.Interaces
{
public interface IFooterRepository
{
List<Footer> GetFooter();
List<Footer> GetFooterWithFooterSocial();
Footer GetFooterById(int id);
Task Add(Footer footer);
void Delete(int id);
void Update(Footer footer);
Task commitAsync();
}
}

View file

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services.Interaces
{
public class IFooterSocialMediaRepository
{
}
}

View file

@ -0,0 +1,28 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Services.Interaces
{
public interface ISocialMediaRepository
{
List<SocialMedia> GetSocialMedia();
List<SocialMedia> GetListofSocialMediaById(List<int> ids);
SocialMedia GetSocialById(int id);
Task Add(SocialMedia socialMedia);
void Delete(int id);
void Update(SocialMedia socialMedia);
Task commitAsync();
}
}

View file

@ -7,7 +7,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" /> <!--<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.3.0" />-->
<!--<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" />-->
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -0,0 +1,175 @@
using Microsoft.AspNetCore.Mvc;
using Model;
using Services.Interaces;
using Web.ViewModel.AddressVM;
namespace Web.Areas.Admin.Controllers
{
public class AddressController : Controller
{
private readonly IAddressRepository _addresContext;
public AddressController(IAddressRepository addresContext)
{
_addresContext = addresContext;
}
public IActionResult Index()
{
var addressFromdb = _addresContext.GetAddresses();
var viewmodel=new List<AddressViewModel>();
foreach (var address in addressFromdb)
{
viewmodel.Add(new AddressViewModel
{
Id=address.Id,
State=address.State,
Street=address.Street,
City=address.City,
PostalCode=address.PostalCode,
Country=address.Country,
CVR=address.CVR,
Email=address.Email,
Mobile=address.Mobile,
});
}
return View(viewmodel);
}
[HttpGet]
public IActionResult Create()
{
return View();
}
[HttpPost]
public async Task<IActionResult> Create(AddressViewModel viewmodel)
{
if(ModelState.IsValid)
{
var addres = new Address
{
Id=viewmodel.Id,
State=viewmodel.State,
Street=viewmodel.Street,
City=viewmodel.City,
PostalCode=viewmodel.PostalCode,
Country=viewmodel.Country,
CVR=viewmodel.CVR,
Email=viewmodel.Email,
Mobile=viewmodel.Mobile,
};
await _addresContext.Add(addres);
await _addresContext.commitAsync();
TempData["Success"] = "Address created successfully";
return RedirectToAction(nameof(Index));
}
return View(viewmodel);
}
[HttpGet]
public IActionResult Edit(int id)
{
var address=_addresContext.GetAddressById(id);
var viewmodel = new AddressViewModel
{
Id=address.Id,
State=address.State,
Street=address.Street,
City=address.City,
PostalCode=address.PostalCode,
Country=address.Country,
CVR=address.CVR,
Email=address.Email,
Mobile=address.Mobile,
};
return View(viewmodel);
}
[HttpPost]
public async Task<IActionResult> Edit(AddressViewModel viewmodel)
{
if(ModelState.IsValid)
{
var addres = _addresContext.GetAddressById(viewmodel.Id);
addres.Id = viewmodel.Id;
addres.State = viewmodel.State;
addres.Street = viewmodel.Street;
addres.City = viewmodel.City;
addres.Country = viewmodel.Country;
addres.Email = viewmodel.Email;
addres.Mobile = viewmodel.Mobile;
addres.CVR = viewmodel.CVR;
addres.PostalCode = viewmodel.PostalCode;
_addresContext.Update(addres);
await _addresContext.commitAsync();
TempData["Success"] = "Address updated successfully";
return RedirectToAction(nameof(Index));
}
return View(viewmodel);
}
[HttpGet]
public IActionResult Delete(int id)
{
var address = _addresContext.GetAddressById(id);
var viewmodel = new AddressViewModel
{
Id = address.Id,
State = address.State,
Street = address.Street,
City = address.City,
PostalCode = address.PostalCode,
Country = address.Country,
CVR = address.CVR,
Email = address.Email,
Mobile = address.Mobile,
};
return View(viewmodel);
}
[HttpPost]
[ActionName("Delete")]
public async Task<IActionResult> DeleteConfirm(int id)
{
_addresContext.Delete(id);
await _addresContext.commitAsync();
TempData["Success"] = "Address deleted successfully";
return RedirectToAction(nameof(Index));
}
}
}

View file

@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc;
namespace Web.Areas.Admin.Controllers
{
public class AdminController : Controller
{
public IActionResult Index()
{
return View();
}
}
}

View file

@ -2,7 +2,7 @@
using Model; using Model;
using Services.Interaces; using Services.Interaces;
using System.Collections.Immutable; using System.Collections.Immutable;
using Web.ViewModel; using Web.ViewModel.BannerVM;
namespace Web.Areas.Admin.Controllers namespace Web.Areas.Admin.Controllers
{ {

View file

@ -0,0 +1,159 @@
using Data;
using Microsoft.AspNetCore.Components.Forms.Mapping;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using Model;
using Services.Interaces;
using Web.ViewModel.FooterVm;
using Web.ViewModel.SocialMediaVM;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace Web.Areas.Admin.Controllers
{
public class FooterController : Controller
{
private readonly IFooterRepository _footer;
private readonly ISocialMediaRepository _socialMedia;
private readonly SurveyContext _context;
public FooterController(IFooterRepository footer,ISocialMediaRepository socialMedia,SurveyContext context)
{
_footer = footer;
_socialMedia = socialMedia;
_context = context;
}
public IActionResult Index()
{
//var footers = _footer.GetFooter();
//var footers = _context.Footers.Include(f => f.FooterSocialMedias)
// .ThenInclude(fsm => fsm.SocialMedia)
// .ToList();
var socialId = _context.FooterSocialMedias.Select(x => x.SocialId).ToList();
var footer = _footer.GetFooterWithFooterSocial();
var footerViewModels = footer.Select(footer => new ShowViewModel
{
Id = footer.Id,
Title=footer.Title,
Name=footer.Name,
Owner=footer.Owner,
CreatedBy=footer.CreatedBy,
// Map other properties from Footer to FooterViewModel as needed
SelectedSocialMediaIds = footer.FooterSocialMedias.Select(fsm => fsm.SocialId).ToList(),
SocialMediaOptions = _context.SocialMedia
.Select(sm => new SelectListItem
{
Value = sm.Id.ToString(),
Text = sm.Name
})
.ToList()
}).ToList();
return View(footerViewModels);
}
[HttpGet]
public IActionResult Create()
{
var socialMediaOptions = _socialMedia.GetSocialMedia()
.Select(sm => new SelectListItem
{
Value = sm.Id.ToString(),
Text = sm.Name // Adjust this based on your SocialMedia properties
})
.ToList();
var viewModel = new InserFooterViewModel
{
SocialMediaOptions = socialMediaOptions
};
return View(viewModel);
}
[HttpPost]
public async Task<IActionResult> Create(InserFooterViewModel viewmodel)
{
if (ModelState.IsValid)
{
var footer = new Footer
{
Id = viewmodel.Id,
Name = viewmodel.Name,
Title = viewmodel.Title,
Owner = viewmodel.Owner,
Content = viewmodel.Content,
CreatedBy = viewmodel.CreatedBy,
UpdatedBy = viewmodel.UpdatedBy,
LastUpdated = viewmodel.LastUpdated,
ImageUlr = viewmodel.ImageUlr,
Sitecopyright = viewmodel.Sitecopyright,
};
if (viewmodel.SelectedSocialMediaIds != null)
{
footer.FooterSocialMedias = viewmodel.SelectedSocialMediaIds
.Select(id => new FooterSocialMedia
{
SocialId = id
})
.ToList();
}
await _footer.Add(footer);
await _footer.commitAsync();
return RedirectToAction("Index"); // Redirect to appropriate action
}
// If ModelState is not valid, re-populate options and return to the view
viewmodel.SocialMediaOptions = _socialMedia.GetSocialMedia()
.Select(sm => new SelectListItem
{
Value = sm.Id.ToString(),
Text = sm.Name // Adjust this based on your SocialMedia properties
})
.ToList();
return View(viewmodel);
}
private List<CheckBoxViewModel> GetsocialMdeia()
{
var socialMedia = _socialMedia.GetSocialMedia();
List<CheckBoxViewModel> selectListItems = new List<CheckBoxViewModel>();
foreach (var item in socialMedia)
{
selectListItems.Add(new CheckBoxViewModel
{
SocialMediaName=item.Name,
SocialMediaId=item.Id,
IsSelected=false,
});
}
return selectListItems;
}
}
}

View file

@ -0,0 +1,65 @@
using Microsoft.AspNetCore.Mvc;
using Model;
using Services.Interaces;
using Web.ViewModel.SocialMediaVM;
namespace Web.Areas.Admin.Controllers
{
public class SocialMediaController : Controller
{
private readonly ISocialMediaRepository _context;
public SocialMediaController(ISocialMediaRepository context)
{
_context = context;
}
public IActionResult Index()
{
var socialMediaFromdb = _context.GetSocialMedia();
var viewmodel = new List<SocialMediaViewModel>();
foreach (var item in socialMediaFromdb)
{
viewmodel.Add(new SocialMediaViewModel
{
Id = item.Id,
Name = item.Name,
Url = item.Url,
}) ;
}
return View(viewmodel);
}
[HttpGet]
public IActionResult Create()
{
return View();
}
[HttpPost]
public async Task<IActionResult> Create(SocialMediaViewModel model)
{
if(ModelState.IsValid)
{
var socialMedia = new SocialMedia
{
Id=model.Id,
Name=model.Name,
Url=model.Url,
};
await _context.Add(socialMedia);
await _context.commitAsync();
TempData["Success"] = "Social media created successfully";
return RedirectToAction(nameof(Index));
}
return View(model);
}
}
}

View file

@ -0,0 +1,83 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Web.Areas.Admin.Controllers
{
public class sdController : Controller
{
// GET: sdController
public ActionResult Index()
{
return View();
}
// GET: sdController/Details/5
public ActionResult Details(int id)
{
return View();
}
// GET: sdController/Create
public ActionResult Create()
{
return View();
}
// POST: sdController/Create
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}
// GET: sdController/Edit/5
public ActionResult Edit(int id)
{
return View();
}
// POST: sdController/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(int id, IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}
// GET: sdController/Delete/5
public ActionResult Delete(int id)
{
return View();
}
// POST: sdController/Delete/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Delete(int id, IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}
}
}

View file

@ -0,0 +1,79 @@
@model AddressViewModel
@{
ViewData["Title"] = "Create";
}
<div class="container mt-4">
<div class="card justify-content-center">
<div class="card-body">
<h5 class="card-title">Create Address</h5>
<div class="row ">
<!-- 12 columns for textboxes -->
<form asp-action="Create" asp-controller="address">
<div asp-validation-summary="All" class="text-danger"></div>
<div class="mb-3 col-12">
<label asp-for="Street" class="control-label"></label>
<input asp-for="Street" class="form-control" />
<span asp-validation-for="Street" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="City" class="control-label"></label>
<input asp-for="City" class="form-control" />
<span asp-validation-for="City" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="State" class="control-label"></label>
<input asp-for="State" class="form-control" />
<span asp-validation-for="State" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="PostalCode" class="control-label"></label>
<input asp-for="PostalCode" class="form-control" />
<span asp-validation-for="PostalCode" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="Country" class="control-label"></label>
<input asp-for="Country" class="form-control" />
<span asp-validation-for="Country" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="CVR" class="control-label"></label>
<input asp-for="CVR" class="form-control" />
<span asp-validation-for="CVR" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="Email" class="control-label"></label>
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="Mobile" class="control-label"></label>
<input asp-for="Mobile" class="form-control" />
<span asp-validation-for="Mobile" 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>
</div>
</form>
</div>
</div>
</div>
</div>
@section Scripts {
@{
<partial name="_ValidationScriptsPartial" />
}
}

View file

@ -0,0 +1,78 @@
@model AddressViewModel
@{
ViewData["Title"] = "Delete";
}
<div class="container mt-4">
<div class="card justify-content-center">
<div class="card-body">
<h5 class="card-title">Delete Address</h5>
<h6 class="text-danger">Are you sure you want to delete the <span class="badge bg-danger">@Model.Country</span></h6>
<div class="row ">
<!-- 12 columns for textboxes -->
<form asp-action="Delete" asp-controller="address">
<div asp-validation-summary="All" class="text-danger"></div>
<div class="mb-3 col-12">
<label asp-for="Street" class="control-label"></label>
<input asp-for="Street" class="form-control" disabled />
<span asp-validation-for="Street" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="City" class="control-label"></label>
<input asp-for="City" class="form-control" disabled />
<span asp-validation-for="City" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="State" class="control-label"></label>
<input asp-for="State" disabled/ class="form-control">
<span asp-validation-for="State" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="PostalCode" class="control-label"></label>
<input asp-for="PostalCode" class="form-control" disabled />
<span asp-validation-for="PostalCode" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="Country" class="control-label"></label>
<input asp-for="Country" class="form-control" disabled />
<span asp-validation-for="Country" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="CVR" class="control-label"></label>
<input asp-for="CVR" class="form-control" disabled />
<span asp-validation-for="CVR" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="Email" class="control-label"></label>
<input asp-for="Email" class="form-control" disabled />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="Mobile" class="control-label"></label>
<input asp-for="Mobile" class="form-control" disabled />
<span asp-validation-for="Mobile" class="text-danger"></span>
</div>
<div class="mb-3">
<input type="submit" value="Delete" class="btn btn-outline-primary" /> | <a asp-action="Index" class="btn btn-primary">Back to list</a>
</div>
</form>
</div>
</div>
</div>
</div>
@section Scripts {
@{
<partial name="_ValidationScriptsPartial" />
}
}

View file

@ -0,0 +1,84 @@
@model AddressViewModel
@{
ViewData["Title"] = "Edit";
}
<div class="container mt-4">
<div class="card justify-content-center">
<div class="card-body">
<h5 class="card-title">Update Address</h5>
<div class="row ">
<!-- 12 columns for textboxes -->
<form asp-action="Edit" asp-controller="address">
<div asp-validation-summary="All" class="text-danger"></div>
<div class="mb-3 col-12">
<label asp-for="Street" class="control-label"></label>
<input asp-for="Street" class="form-control" />
<span asp-validation-for="Street" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="City" class="control-label"></label>
<input asp-for="City" class="form-control"/>
<span asp-validation-for="City" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="State" class="control-label"></label>
<input asp-for="State" class="form-control" />
<span asp-validation-for="State" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="PostalCode" class="control-label"></label>
<input asp-for="PostalCode" class="form-control" />
<span asp-validation-for="PostalCode" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="Country" class="control-label"></label>
<input asp-for="Country" class="form-control" />
<span asp-validation-for="Country" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="CVR" class="control-label"></label>
<input asp-for="CVR" class="form-control" />
<span asp-validation-for="CVR" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="Email" class="control-label"></label>
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="Mobile" class="control-label"></label>
<input asp-for="Mobile" class="form-control" />
<span asp-validation-for="Mobile" 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>
</div>
</form>
</div>
</div>
</div>
</div>
@section Scripts {
@{
<partial name="_ValidationScriptsPartial" />
}
}

View file

@ -0,0 +1,59 @@
@model IEnumerable<AddressViewModel>
@{
ViewData["Title"] = "Address";
}
<div class="container mt-5">
<partial name="_Notification" />
<div class="card bg-default mb-3 ">
<div class="card-header">Address</div>
<div class="card-body">
<h4 class="card-title">Address list</h4>
<p>
<a asp-action="Create" class="btn btn-primary">Create New</a>
</p>
<table class="table table-hover table-responsive table-striped ">
<thead>
<tr>
<th scope="col">Id</th>
<th scope="col">Street</th>
<th scope="col">City</th>
<th scope="col">State</th>
<th scope="col">Country</th>
<th scope="col">CVR</th>
<th scope="col">Email</th>
<th scope="col">Mobile</th>
<th scope="col" class="d-flex justify-content-end">Action</th>
</tr>
</thead>
<tbody class="justify-content-center">
@foreach (var item in Model)
{
<tr class=" table-secondary">
<td>@item.Id</td>
<td>@item.Street</td>
<td>@item.City</td>
<td>@item.State</td>
<td>@item.Country</td>
<td>@item.CVR</td>
<td>@item.Email</td>
<td>@item.Mobile</td>
<td class="d-flex justify-content-end">
<a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger btn-m"><i class="bi bi-trash"></i> Delete</a> |
<a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-warning btn-m"><i class="bi bi-pencil-square"></i> Edit</a>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>

View file

@ -0,0 +1 @@


View file

@ -64,55 +64,3 @@
} }
} }
@* <div>
<hr />
<dl class="row">
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.Id)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.Id)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.Title)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.Title)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.Description)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.Description)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.Content)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.Content)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.LinkUrl)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.LinkUrl)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.ImageUrl)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.ImageUrl)
</dd>
</dl>
<form asp-action="Delete">
<input type="submit" value="Delete" class="btn btn-danger" /> |
<a asp-action="Index">Back to List</a>
</form>
</div> *@

View file

@ -63,47 +63,3 @@
} }
<hr />
@* <div class="row">
<div class="col-md-4">
<form asp-action="Edit">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="Id" class="control-label"></label>
<input asp-for="Id" class="form-control" />
<span asp-validation-for="Id" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Title" class="control-label"></label>
<input asp-for="Title" class="form-control" />
<span asp-validation-for="Title" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Description" class="control-label"></label>
<input asp-for="Description" class="form-control" />
<span asp-validation-for="Description" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Content" class="control-label"></label>
<input asp-for="Content" class="form-control" />
<span asp-validation-for="Content" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="LinkUrl" class="control-label"></label>
<input asp-for="LinkUrl" class="form-control" />
<span asp-validation-for="LinkUrl" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="ImageUrl" class="control-label"></label>
<input asp-for="ImageUrl" class="form-control" />
<span asp-validation-for="ImageUrl" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Save" class="btn btn-primary" />
</div>
</form>
</div>
</div> *@

View file

@ -1,15 +1,15 @@
@model IEnumerable<BannerViewModel> @model IEnumerable<BannerViewModel>
@{ @{
ViewData["Title"] = "Index"; ViewData["Title"] = "Banner";
} }
<div class="container"> <div class="container mt-5">
<partial name="_Notification"/> <partial name="_Notification"/>
<div class="card text-white bg-info mb-3 justify-content-center"> <div class="card bg-default mb-3 ">
<div class="card-header">Banners</div> <div class="card-header">Banners</div>
<div class="card-body"> <div class="card-body">
<h4 class="card-title">Banner list</h4> <h4 class="card-title">Banner list</h4>
@ -17,7 +17,7 @@
<a asp-action="Create" class="btn btn-primary">Create New</a> <a asp-action="Create" class="btn btn-primary">Create New</a>
</p> </p>
<table class="table table-hover table-responsive"> <table class="table table-hover table-responsive table-striped ">
<thead> <thead>
<tr> <tr>
@ -28,7 +28,7 @@
<th scope="col" class="d-flex justify-content-end">Action</th> <th scope="col" class="d-flex justify-content-end">Action</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="">
@foreach (var item in Model) @foreach (var item in Model)
{ {
<tr class="table-secondary"> <tr class="table-secondary">
@ -38,8 +38,8 @@
<td>@item.Description</td> <td>@item.Description</td>
<td>@item.LinkUrl</td> <td>@item.LinkUrl</td>
<td class="d-flex justify-content-end"> <td class="d-flex justify-content-end">
<a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger"><i class="bi bi-trash"></i> Delete</a> | <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"><i class="bi bi-pencil-square"></i> Edit</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>
</td> </td>
</tr> </tr>
} }
@ -64,3 +64,5 @@

View file

@ -0,0 +1,124 @@
@model InserFooterViewModel
@{
// ViewData["Title"] = "Create";
}
<div class="container mt-4">
<div class="card justify-content-center">
<div class="card-body">
<h5 class="card-title">Create Footer</h5>
<div class="row ">
<!-- 12 columns for textboxes -->
<form asp-action="Create">
<div asp-validation-summary="All" class="text-danger"></div>
<div class="mb-3 col-12">
<label asp-for="Title" class="control-label"></label>
<input asp-for="Title" class="form-control" />
<span asp-validation-for="Title" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="Name" class="control-label"></label>
<input asp-for="Name" class="form-control" />
<span asp-validation-for="Name" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="Content" class="control-label"></label>
<textarea asp-for="Content"></textarea>
<span asp-validation-for="Content" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="Owner" class="control-label"></label>
<input asp-for="Owner" class="form-control" />
<span asp-validation-for="Owner" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="CreatedBy" class="control-label"></label>
<input asp-for="CreatedBy" class="form-control" />
<span asp-validation-for="CreatedBy" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="LastUpdated" class="control-label"></label>
<input asp-for="LastUpdated" class="form-control" />
<span asp-validation-for="LastUpdated" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="UpdatedBy" class="control-label"></label>
<input asp-for="UpdatedBy" class="form-control" />
<span asp-validation-for="UpdatedBy" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="ImageUlr" class="control-label"></label>
<input asp-for="ImageUlr" class="form-control" />
<span asp-validation-for="ImageUlr" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="Sitecopyright" class="control-label"></label>
<input asp-for="Sitecopyright" class="form-control" />
<span asp-validation-for="Sitecopyright" class="text-danger"></span>
</div>
<div>
<fieldset>
<legend>Select Social Media: </legend>
@foreach (var option in Model.SocialMediaOptions)
{
<input type="checkbox" name="SelectedSocialMediaIds" value="@option.Value"
@(Model.SelectedSocialMediaIds != null && Model.SelectedSocialMediaIds.Contains(int.Parse(option.Value)) ? "checked" : "")>
@option.Text
<br>
}
</fieldset>
</div>
@*
<fieldset>
<legend>Select Social Media:</legend>
@for (var i = 0; i < Model.CheckBoxViewModel.Count; i++)
{
<div>
<input type="checkbox" name="SocialMediaOptions[@i].IsSelected" />
<label>@Model.CheckBoxViewModel[i].SocialMediaName</label>
<input type="hidden" name="SocialMediaOptions[@i].SocialMediaId" value="@Model.CheckBoxViewModel[i].SocialMediaId" />
</div>
}
</fieldset> *@
<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>
</div>
</form>
</div>
</div>
</div>
</div>
@section Scripts {
<script src="https://cdnjs.cloudflare.com/ajax/libs/ckeditor/4.11.4/ckeditor.js"></script>
<script>
CKEDITOR.replace("Content");
</script>
@{
<partial name="_ValidationScriptsPartial" />
}
}

View file

@ -0,0 +1,168 @@
@model IEnumerable<ShowViewModel>
@{
ViewData["Title"] = "Index";
}
<div class="container mt-5">
<partial name="_Notification" />
<div class="card bg-default mb-3 ">
<div class="card-header">Address</div>
<div class="card-body">
<h4 class="card-title">Address list</h4>
<p>
<a asp-action="Create" class="btn btn-primary">Create New</a>
</p>
<table class="table table-hover table-responsive table-striped ">
<thead class="justify-content-center">
<tr>
<th scope="col">Id</th>
<th scope="col">Title</th>
<th scope="col">Name</th>
<th scope="col">Owner</th>
<th scope="col">Created By</th>
<th scope="col">Social Media</th>
<th scope="col" class="d-flex justify-content-end">Action</th>
</tr>
</thead>
<tbody class="justify-content-center">
@foreach (var item in Model)
{
<tr class=" table-secondary">
<td>@item.Id</td>
<td>@item.Title</td>
<td>@item.Name</td>
<td>@item.Owner</td>
<td>@item.CreatedBy</td>
<td>
<fieldset>
<legend></legend>
@foreach (var option in item.SocialMediaOptions)
{
<input type="checkbox" name="SelectedSocialMediaIds" value="@option.Value" disabled
@(item.SelectedSocialMediaIds != null && item.SelectedSocialMediaIds.Contains(int.Parse(option.Value)) ? "checked" : "unchecked")>
@option.Text
<br>
}
</fieldset>
</td>
<td class="d-flex justify-content-end">
<a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger btn-m"><i class="bi bi-trash"></i> Delete</a> |
<a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-warning btn-m"><i class="bi bi-pencil-square"></i> Edit</a>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
@*
<h1>Index</h1>
<p>
<a asp-action="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Id)
</th>
<th>
@Html.DisplayNameFor(model => model.Title)
</th>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Owner)
</th>
<th>
@Html.DisplayNameFor(model => model.Content)
</th>
<th>
@Html.DisplayNameFor(model => model.CreatedBy)
</th>
<th>
@Html.DisplayNameFor(model => model.UpdatedBy)
</th>
<th>
@Html.DisplayNameFor(model => model.LastUpdated)
</th>
<th>
@Html.DisplayNameFor(model => model.ImageUlr)
</th>
<th>
@Html.DisplayNameFor(model => model.Sitecopyright)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Owner)
</td>
<td>
@Html.DisplayFor(modelItem => item.Content)
</td>
<td>
@Html.DisplayFor(modelItem => item.CreatedBy)
</td>
<td>
@Html.DisplayFor(modelItem => item.UpdatedBy)
</td>
<td>
@Html.DisplayFor(modelItem => item.LastUpdated)
</td>
<td>
@Html.DisplayFor(modelItem => item.ImageUlr)
</td>
<td>
@Html.DisplayFor(modelItem => item.Sitecopyright)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
</td>
</tr>
}
</tbody>
</table>
*@

View file

@ -12,38 +12,81 @@
</head> </head>
<body> <body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"> <div class="wrapper d-flex align-items-stretch">
<nav id="sidebar" class="active">
<h1><a class="logo">OS</a></h1>
<ul class="list-unstyled components mb-5">
<li class="sidebarCollapse">
<a asp-controller="admin" asp-action="index"><span class="bi bi-speedometer"></span> Admin</a>
</li>
<li>
<a asp-controller="Page" asp-action="index"><span class="bi bi-file-earmark-fill"></span> Pages</a>
</li>
<li>
<a asp-controller="banner" asp-action="index"><span class="bi bi-card-image"></span> Banners</a>
</li>
<li>
<a asp-controller="footer" asp-action="index"><span class="bi bi-c-circle-fill"></span> Footer</a>
</li>
<li>
<a asp-controller="address" asp-action="index"><span class="bi bi-pin-map"></span> Address</a>
</li>
<li>
<a asp-controller="SocialMedia" asp-action="index"><span class="bi bi-collection-play-fill"></span> Social Media</a>
</li>
</ul>
</nav>
<!-- Page Content -->
<div id="content" class="p-4 p-md-5">
<nav class="navbar navbar-expand-lg navbar-light bg-brimary">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" asp-area="admin" asp-controller="Home" asp-action="Index">Web</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent" <button type="button" id="sidebarCollapse" class="btn btn-primary">
aria-expanded="false" aria-label="Toggle navigation"> <i class="bi bi-list"></i>
<span class="navbar-toggler-icon"></span> <span class="sr-only">Toggle Menu</span>
</button> </button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between"> <button class="navbar-toggler btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
<ul class="navbar-nav flex-grow-1"> aria-expanded="false" aria-label="Toggle navigation">
<li class="nav-item"> <i class="bi bi-list"></i>
<a class="nav-link text-dark" asp-area="admin" asp-controller="Home" asp-action="Index">Home</a> <span class="sr-only"></span>
</button>
<div class=" collapse navbar-collapse" id="navbarSupportedContent">
<ul class="nav navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="admin" asp-controller="Home" asp-action="Privacy">Privacy</a> <a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class=" link-primary nav-link" href="#">Portfolio</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
</nav> </nav>
</header>
<div class="container">
<main role="main" class="pb-3"> <main class="container-fluid mt-5">
@RenderBody() @RenderBody()
</main> </main>
</div>
</div> </div>
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2024 - Web - <a asp-area="admin" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script> <script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script> <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script> <script src="~/js/site.js" asp-append-version="true"></script>

View file

@ -0,0 +1,46 @@
@model SocialMediaViewModel
@{
ViewData["Title"] = "Create";
}
<div class="container mt-4">
<div class="card justify-content-center">
<div class="card-body">
<h5 class="card-title">Create social media</h5>
<div class="row ">
<!-- 12 columns for textboxes -->
<form asp-action="Create">
<div asp-validation-summary="All" class="text-danger"></div>
<div class="mb-3 col-12">
<label asp-for="Name" class="control-label"></label>
<input asp-for="Name" class="form-control" />
<span asp-validation-for="Name" class="text-danger"></span>
</div>
<div class="mb-3 col-12">
<label asp-for="Url" class="control-label"></label>
<input asp-for="Url" class="form-control" />
<span asp-validation-for="Url" 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>
</div>
</form>
</div>
</div>
</div>
</div>
@section Scripts {
@{
<partial name="_ValidationScriptsPartial" />
}
}

View file

@ -0,0 +1,51 @@
@model IEnumerable<SocialMediaViewModel>
@{
ViewData["Title"] = "Index";
}
<div class="container mt-5">
<partial name="_Notification" />
<div class="card bg-default mb-3 ">
<div class="card-header">Social Media</div>
<div class="card-body">
<h4 class="card-title">Social Media list</h4>
<p>
<a asp-action="Create" class="btn btn-primary">Create New</a>
</p>
<table class="table table-hover table-responsive table-striped ">
<thead>
<tr>
<th scope="col">Id</th>
<th scope="col">Name</th>
<th scope="col">Link Url</th>
<th scope="col" class="d-flex justify-content-end">Action</th>
</tr>
</thead>
<tbody class="justify-content-center">
@foreach (var item in Model)
{
<tr class="table-secondary">
<td>@item.Id</td>
<td> <span class="badge bg-primary">@item.Name</span></td>
<td>@item.Url</td>
<td class="d-flex justify-content-end">
<a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger btn-m"><i class="bi bi-trash"></i> Delete</a> |
<a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-warning btn-m"><i class="bi bi-pencil-square"></i> Edit</a>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>

View file

@ -1,4 +1,8 @@
@using Web @using Web
@using Web.Models @using Web.Models
@using Web.ViewModel @using Web.ViewModel
@using Web.ViewModel.AddressVM
@using Web.ViewModel.BannerVM
@using Web.ViewModel.FooterVm
@using Web.ViewModel.SocialMediaVM
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View file

@ -23,5 +23,20 @@ namespace Web.Extesions
{ {
services.AddScoped<IBannerRepository, BannerRepository>(); services.AddScoped<IBannerRepository, BannerRepository>();
} }
public static void ConfigureAddress(this IServiceCollection services)
{
services.AddScoped<IAddressRepository, AddressRepository>();
}
public static void ConfigureSocialMedia(this IServiceCollection services)
{
services.AddScoped<ISocialMediaRepository,SocialMediaRepository>();
}
public static void ConfigureFooter(this IServiceCollection services)
{
services.AddScoped<IFooterRepository, FooterRepository>();
}
} }
} }

View file

@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Web.Migrations namespace Web.Migrations
{ {
[DbContext(typeof(SurveyContext))] [DbContext(typeof(SurveyContext))]
[Migration("20240220174310_initial")] [Migration("20240228172237_Initial")]
partial class initial partial class Initial
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -149,6 +149,21 @@ namespace Web.Migrations
b.ToTable("Footers"); 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 => modelBuilder.Entity("Model.Page", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -178,6 +193,46 @@ namespace Web.Migrations
b.ToTable("Pages"); 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 => modelBuilder.Entity("Model.Page", b =>
{ {
b.HasOne("Model.Banner", "banner") b.HasOne("Model.Banner", "banner")
@ -188,6 +243,16 @@ namespace Web.Migrations
b.Navigation("banner"); b.Navigation("banner");
}); });
modelBuilder.Entity("Model.Footer", b =>
{
b.Navigation("FooterSocialMedias");
});
modelBuilder.Entity("Model.SocialMedia", b =>
{
b.Navigation("FooterSocialMedias");
});
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }

View file

@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace Web.Migrations namespace Web.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class initial : Migration public partial class Initial : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
@ -69,6 +69,20 @@ namespace Web.Migrations
table.PrimaryKey("PK_Footers", x => x.Id); table.PrimaryKey("PK_Footers", x => x.Id);
}); });
migrationBuilder.CreateTable(
name: "SocialMedia",
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),
Url = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SocialMedia", x => x.Id);
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Pages", name: "Pages",
columns: table => new columns: table => new
@ -91,6 +105,35 @@ namespace Web.Migrations
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable(
name: "FooterSocialMedias",
columns: table => new
{
FooterId = table.Column<int>(type: "int", nullable: false),
SocialId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_FooterSocialMedias", x => new { x.FooterId, x.SocialId });
table.ForeignKey(
name: "FK_FooterSocialMedias_Footers_FooterId",
column: x => x.FooterId,
principalTable: "Footers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_FooterSocialMedias_SocialMedia_SocialId",
column: x => x.SocialId,
principalTable: "SocialMedia",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_FooterSocialMedias_SocialId",
table: "FooterSocialMedias",
column: "SocialId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Pages_BannerId", name: "IX_Pages_BannerId",
table: "Pages", table: "Pages",
@ -104,11 +147,17 @@ namespace Web.Migrations
name: "Addresss"); name: "Addresss");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Footers"); name: "FooterSocialMedias");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Pages"); name: "Pages");
migrationBuilder.DropTable(
name: "Footers");
migrationBuilder.DropTable(
name: "SocialMedia");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Banners"); name: "Banners");
} }

View file

@ -146,6 +146,21 @@ namespace Web.Migrations
b.ToTable("Footers"); 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 => modelBuilder.Entity("Model.Page", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -175,6 +190,46 @@ namespace Web.Migrations
b.ToTable("Pages"); 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 => modelBuilder.Entity("Model.Page", b =>
{ {
b.HasOne("Model.Banner", "banner") b.HasOne("Model.Banner", "banner")
@ -185,6 +240,16 @@ namespace Web.Migrations
b.Navigation("banner"); b.Navigation("banner");
}); });
modelBuilder.Entity("Model.Footer", b =>
{
b.Navigation("FooterSocialMedias");
});
modelBuilder.Entity("Model.SocialMedia", b =>
{
b.Navigation("FooterSocialMedias");
});
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }

View file

@ -14,6 +14,9 @@ builder.Services.ConfigureSQLConnection(builder.Configuration);
builder.Services.ConfigurePageServices(); builder.Services.ConfigurePageServices();
builder.Services.ConfigureBannerServices(); builder.Services.ConfigureBannerServices();
builder.Services.ConfigureAddress();
builder.Services.ConfigureSocialMedia();
builder.Services.ConfigureFooter();
var app = builder.Build(); var app = builder.Build();

View file

@ -0,0 +1,34 @@
using System.ComponentModel.DataAnnotations;
namespace Web.ViewModel.AddressVM
{
public class AddressViewModel
{
public int Id { get; set; }
[Required]
public string? Street { get; set; }
[Required]
public string? City { get; set; }
public string? State { get; set; }
[Required]
[DataType(DataType.PostalCode)]
public string? PostalCode { get; set; }
[Required]
public string? Country { get; set; }
public string? CVR { get; set; }
[Required]
[DataType(DataType.EmailAddress)]
public string? Email { get; set; }
[Required]
[DataType(DataType.PhoneNumber)]
public string? Mobile { get; set; }
}
}

View file

@ -1,7 +1,7 @@
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Web.ViewModel namespace Web.ViewModel.BannerVM
{ {
public class BannerViewModel public class BannerViewModel
{ {

View file

@ -0,0 +1,38 @@
using Model;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace Web.ViewModel.FooterVm
{
public class FooterViewModel
{
public int Id { get; set; }
[Required]
public string? Title { get; set; }
[Required]
public string? Name { get; set; }
[Required]
public string? Owner { get; set; }
[Required]
public string? Content { get; set; }
[Required]
public string? CreatedBy { get; set; }
[Required]
public string? UpdatedBy { get; set; }
public DateTime LastUpdated { get; set; }
[Required]
[DataType(DataType.Url)]
[DisplayName("Image Url")]
public string? ImageUlr { get; set; }
[Required]
public string? Sitecopyright { get; set; }
public List<SocialMedia>? SocialMediaList { get; set; }
}
}

View file

@ -0,0 +1,45 @@
using Model;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using Microsoft.AspNetCore.Mvc.Rendering;
using Web.ViewModel.SocialMediaVM;
namespace Web.ViewModel.FooterVm
{
public class InserFooterViewModel
{
//public InserFooterViewModel()
//{
// SocialMediaOptions = new List<SelectListItem>();
//}
public int Id { get; set; }
[Required]
public string? Title { get; set; }
[Required]
public string? Name { get; set; }
[Required]
public string? Owner { get; set; }
[Required]
public string? Content { get; set; }
[Required]
public string? CreatedBy { get; set; }
[Required]
public string? UpdatedBy { get; set; }
public DateTime LastUpdated { get; set; }
[Required]
[DataType(DataType.Url)]
[DisplayName("Image Url")]
public string? ImageUlr { get; set; }
[Required]
public string? Sitecopyright { get; set; }
public List<int>? SelectedSocialMediaIds { get; set; }
public List<SelectListItem>? SocialMediaOptions { get; set; }
}
}

View file

@ -0,0 +1,40 @@
using Microsoft.AspNetCore.Mvc.Rendering;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using Model;
namespace Web.ViewModel.FooterVm
{
public class ShowViewModel
{
public int Id { get; set; }
[Required]
public string? Title { get; set; }
[Required]
public string? Name { get; set; }
[Required]
public string? Owner { get; set; }
[Required]
public string? Content { get; set; }
[Required]
public string? CreatedBy { get; set; }
[Required]
public string? UpdatedBy { get; set; }
public DateTime LastUpdated { get; set; }
[Required]
[DataType(DataType.Url)]
[DisplayName("Image Url")]
public string? ImageUlr { get; set; }
[Required]
public string? Sitecopyright { get; set; }
public List<int>? SelectedSocialMediaIds { get; set; }
public List<SelectListItem>? SocialMediaOptions { get; set; }
}
}

View file

@ -0,0 +1,9 @@
namespace Web.ViewModel.SocialMediaVM
{
public class CheckBoxViewModel
{
public int SocialMediaId { get; set; }
public string? SocialMediaName { get; set; }
public bool IsSelected { get; set; }
}
}

View file

@ -0,0 +1,21 @@
using Model;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
namespace Web.ViewModel.SocialMediaVM
{
public class SocialMediaViewModel
{
public int Id { get; set; }
[Required]
public string? Name { get; set; }
[Required]
[DataType(DataType.Url)]
public string? Url { get; set; }
}
}

View file

@ -6,6 +6,10 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Content Remove="wwwroot\css\Style.css" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter" Version="8.0.2" /> <PackageReference Include="Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2">
@ -21,8 +25,4 @@
<ProjectReference Include="..\Services\Services.csproj" /> <ProjectReference Include="..\Services\Services.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project> </Project>

View file

@ -0,0 +1,3 @@
body {
background-color:red;
}

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,19 @@
// Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification (function ($) {
// for details on configuring this project to bundle and minify static web assets.
// Write your JavaScript code. "use strict";
var fullHeight = function () {
$('.js-fullheight').css('height', $(window).height());
$(window).resize(function () {
$('.js-fullheight').css('height', $(window).height());
});
};
fullHeight();
$('#sidebarCollapse').on('click', function () {
$('#sidebar').toggleClass('active');
});
})(jQuery);