Survey Models Created
This commit is contained in:
parent
3a8f1405b5
commit
78ed96237d
36 changed files with 1638 additions and 35 deletions
|
|
@ -26,6 +26,13 @@ namespace Data
|
||||||
|
|
||||||
public DbSet<FooterSocialMedia> FooterSocialMedias { get; set; }
|
public DbSet<FooterSocialMedia> FooterSocialMedias { get; set; }
|
||||||
|
|
||||||
|
public DbSet<Questionnaire> Questionnaires { get; set; }
|
||||||
|
|
||||||
|
public DbSet<Question> Questions { get; set; }
|
||||||
|
public DbSet<Answer> Answers { get; set; }
|
||||||
|
|
||||||
|
public DbSet<QuestionTypeEntities> QuestionTypeEntities { get; set; }
|
||||||
|
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
|
|
@ -43,7 +50,26 @@ namespace Data
|
||||||
.HasForeignKey(fsm => fsm.SocialId);
|
.HasForeignKey(fsm => fsm.SocialId);
|
||||||
|
|
||||||
|
|
||||||
|
modelBuilder.Entity<Questionnaire>()
|
||||||
|
.HasKey(q => q.Id);
|
||||||
|
|
||||||
|
modelBuilder.Entity<Questionnaire>()
|
||||||
|
.HasMany(q => q.Questions)
|
||||||
|
.WithOne(qn => qn.Questionnaire)
|
||||||
|
.HasForeignKey(qn => qn.QuestionnaireId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<Question>()
|
||||||
|
.HasOne(q => q.Questionnaire)
|
||||||
|
.WithMany(qn => qn.Questions)
|
||||||
|
.HasForeignKey(q => q.QuestionnaireId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<Answer>()
|
||||||
|
.HasKey(a => a.Id);
|
||||||
|
|
||||||
|
modelBuilder.Entity<QuestionTypeEntities>()
|
||||||
|
.HasKey(t => t.Id);
|
||||||
|
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
Model/Answer.cs
Normal file
18
Model/Answer.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
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 Answer
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string? Text { get; set; }
|
||||||
|
public int QuestionId { get; set; } // Foreign key for Question
|
||||||
|
[ForeignKey("QuestionId")]
|
||||||
|
public Question? Question { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
24
Model/Question.cs
Normal file
24
Model/Question.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
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 Question
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string? Text { get; set; }
|
||||||
|
public QuestionType Type { get; set; }
|
||||||
|
|
||||||
|
// Foreign key for Questionnaire
|
||||||
|
|
||||||
|
public int QuestionnaireId { get; set; } // Foreign key for Questionnaire
|
||||||
|
[ForeignKey("QuestionnaireId")]
|
||||||
|
public Questionnaire? Questionnaire { get; set; }
|
||||||
|
|
||||||
|
public List<Answer>? Answers { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
25
Model/QuestionType.cs
Normal file
25
Model/QuestionType.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Model
|
||||||
|
{
|
||||||
|
public enum QuestionType
|
||||||
|
{
|
||||||
|
Text,
|
||||||
|
CheckBox,
|
||||||
|
TrueFalse,
|
||||||
|
Multiple_choice,
|
||||||
|
Rating,
|
||||||
|
Likert,
|
||||||
|
Matrix,
|
||||||
|
Open_ended,
|
||||||
|
Demographic,
|
||||||
|
Ranking,
|
||||||
|
Image,
|
||||||
|
Slider
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
17
Model/QuestionTypeEntities.cs
Normal file
17
Model/QuestionTypeEntities.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Model
|
||||||
|
{
|
||||||
|
public class QuestionTypeEntities
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
|
public QuestionType Type { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
16
Model/Questionnaire.cs
Normal file
16
Model/Questionnaire.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Model
|
||||||
|
{
|
||||||
|
public class Questionnaire
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string? Title { get; set; }
|
||||||
|
public string? Description { get; set; }
|
||||||
|
public List<Question>? Questions { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -31,14 +31,14 @@ namespace Services.Implemnetation
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Delete(int id)
|
public void Delete(int? id)
|
||||||
{
|
{
|
||||||
var addresId = GetAddressById(id);
|
var addresId = GetAddressById(id);
|
||||||
|
|
||||||
_context.Addresss.Remove(addresId);
|
_context.Addresss.Remove(addresId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Address GetAddressById(int id)
|
public Address GetAddressById(int? id)
|
||||||
{
|
{
|
||||||
return _context.Addresss.AsNoTracking().Where(x => x.Id == id).FirstOrDefault();
|
return _context.Addresss.AsNoTracking().Where(x => x.Id == id).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,12 +49,35 @@ namespace Services.Implemnetation
|
||||||
|
|
||||||
public void Update(Footer footer)
|
public void Update(Footer footer)
|
||||||
{
|
{
|
||||||
|
|
||||||
_context.Footers.Update(footer);
|
_context.Footers.Update(footer);
|
||||||
|
//_context.Entry(footer).State = EntityState.Modified;
|
||||||
|
|
||||||
|
|
||||||
|
//foreach (var fsm in footer.FooterSocialMedias)
|
||||||
|
//{
|
||||||
|
// var existingEntity = _context.ChangeTracker.Entries<FooterSocialMedia>()
|
||||||
|
// .FirstOrDefault(e => e.Entity.FooterId == fsm.FooterId && e.Entity.SocialId == fsm.SocialId);
|
||||||
|
|
||||||
|
// if (existingEntity != null)
|
||||||
|
// {
|
||||||
|
// _context.Entry(existingEntity.Entity).State = EntityState.Detached;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// _context.Entry(fsm).State = EntityState.Modified;
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Footer> GetFooterWithFooterSocial()
|
public List<Footer> GetFooterWithFooterSocial()
|
||||||
{
|
{
|
||||||
return _context.Footers.AsNoTracking().Include(x => x.FooterSocialMedias).ThenInclude(x => x.SocialMedia).ToList();
|
return _context.Footers.AsNoTracking().Include(x => x.FooterSocialMedias).ThenInclude(x => x.SocialMedia).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Footer GetFooterByIdWithSocialMedia(int id)
|
||||||
|
{
|
||||||
|
return _context.Footers.AsNoTracking().Include(x => x.FooterSocialMedias).ThenInclude(x => x.SocialMedia).SingleOrDefault(x=>x.Id==id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
58
Services/Implemnetation/QuestionnaireRepository.cs
Normal file
58
Services/Implemnetation/QuestionnaireRepository.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
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 QuestionnaireRepository : IQuestionnaireRepository
|
||||||
|
{
|
||||||
|
private readonly SurveyContext _context;
|
||||||
|
|
||||||
|
public QuestionnaireRepository(SurveyContext Context)
|
||||||
|
{
|
||||||
|
_context = Context;
|
||||||
|
}
|
||||||
|
public void Add(Questionnaire questionnaire)
|
||||||
|
{
|
||||||
|
_context.Questionnaires.Add(questionnaire);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task commitAsync()
|
||||||
|
{
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete(int? id)
|
||||||
|
{
|
||||||
|
var questionnairId = GetQuesById(id);
|
||||||
|
|
||||||
|
_context.Questionnaires.Remove(questionnairId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Questionnaire> GetAllQuestions()
|
||||||
|
{
|
||||||
|
return _context.Questionnaires.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Questionnaire GetQuesById(int? id)
|
||||||
|
{
|
||||||
|
return _context.Questionnaires.Find(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Questionnaire> GetQuestionnairesWithQuestion()
|
||||||
|
{
|
||||||
|
return _context.Questionnaires.AsNoTracking().Include(x=>x.Questions).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(Questionnaire questionnaire)
|
||||||
|
{
|
||||||
|
_context.Questionnaires.Update(questionnaire);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -50,7 +50,7 @@ namespace Services.Implemnetation
|
||||||
|
|
||||||
public List<SocialMedia> GetSocialMedia()
|
public List<SocialMedia> GetSocialMedia()
|
||||||
{
|
{
|
||||||
return _context.SocialMedia.ToList();
|
return _context.SocialMedia.AsNoTracking().ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(SocialMedia socialMedia)
|
public void Update(SocialMedia socialMedia)
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,11 @@ namespace Services.Interaces
|
||||||
|
|
||||||
List<Address> GetAddresses();
|
List<Address> GetAddresses();
|
||||||
|
|
||||||
Address GetAddressById(int id);
|
Address GetAddressById(int? id);
|
||||||
|
|
||||||
Task Add(Address address);
|
Task Add(Address address);
|
||||||
|
|
||||||
void Delete(int id);
|
void Delete(int? id);
|
||||||
|
|
||||||
void Update(Address address);
|
void Update(Address address);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ namespace Services.Interaces
|
||||||
|
|
||||||
Footer GetFooterById(int id);
|
Footer GetFooterById(int id);
|
||||||
|
|
||||||
|
Footer GetFooterByIdWithSocialMedia(int id);
|
||||||
|
|
||||||
Task Add(Footer footer);
|
Task Add(Footer footer);
|
||||||
|
|
||||||
void Delete(int id);
|
void Delete(int id);
|
||||||
|
|
|
||||||
22
Services/Interaces/IQuestionnaireRepository.cs
Normal file
22
Services/Interaces/IQuestionnaireRepository.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
using Model;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Services.Interaces
|
||||||
|
{
|
||||||
|
public interface IQuestionnaireRepository
|
||||||
|
{
|
||||||
|
List<Questionnaire> GetAllQuestions();
|
||||||
|
List<Questionnaire> GetQuestionnairesWithQuestion();
|
||||||
|
Questionnaire GetQuesById(int? id);
|
||||||
|
|
||||||
|
void Add(Questionnaire questionnaire);
|
||||||
|
void Update(Questionnaire questionnaire);
|
||||||
|
void Delete(int? id);
|
||||||
|
|
||||||
|
Task commitAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
using Data;
|
using Data;
|
||||||
using Microsoft.AspNetCore.Components.Forms.Mapping;
|
using Microsoft.AspNetCore.Components.Forms.Mapping;
|
||||||
|
using Microsoft.AspNetCore.Components.Routing;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Model;
|
using Model;
|
||||||
|
using Services.Implemnetation;
|
||||||
using Services.Interaces;
|
using Services.Interaces;
|
||||||
using Web.ViewModel.FooterVm;
|
using Web.ViewModel.FooterVm;
|
||||||
using Web.ViewModel.SocialMediaVM;
|
using Web.ViewModel.SocialMediaVM;
|
||||||
|
|
@ -119,6 +121,7 @@ namespace Web.Areas.Admin.Controllers
|
||||||
|
|
||||||
await _footer.Add(footer);
|
await _footer.Add(footer);
|
||||||
await _footer.commitAsync();
|
await _footer.commitAsync();
|
||||||
|
TempData["Success"] = "Footer created successfully";
|
||||||
return RedirectToAction("Index"); // Redirect to appropriate action
|
return RedirectToAction("Index"); // Redirect to appropriate action
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,24 +139,164 @@ namespace Web.Areas.Admin.Controllers
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CheckBoxViewModel> GetsocialMdeia()
|
[HttpGet]
|
||||||
|
public IActionResult Edit(int id)
|
||||||
{
|
{
|
||||||
var socialMedia = _socialMedia.GetSocialMedia();
|
|
||||||
|
var footer = _footer.GetFooterByIdWithSocialMedia(id);
|
||||||
|
|
||||||
|
var socialMediaOptions =_socialMedia.GetSocialMedia()
|
||||||
|
.Select(sm => new SelectListItem
|
||||||
|
{
|
||||||
|
Value = sm.Id.ToString(),
|
||||||
|
Text = sm.Name,
|
||||||
|
Selected = footer.FooterSocialMedias.Any(fsm => fsm.SocialId == sm.Id)
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var footerViewModel = new FooterEditViewModel
|
||||||
|
{
|
||||||
|
Id = footer.Id,
|
||||||
|
Title = footer.Title,
|
||||||
|
Name = footer.Name,
|
||||||
|
Owner = footer.Owner,
|
||||||
|
Content = footer.Content,
|
||||||
|
CreatedBy = footer.CreatedBy,
|
||||||
|
UpdatedBy = footer.UpdatedBy,
|
||||||
|
LastUpdated = footer.LastUpdated,
|
||||||
|
ImageUlr = footer.ImageUlr,
|
||||||
|
Sitecopyright = footer.Sitecopyright,
|
||||||
|
// Map other properties from Footer to FooterViewModel as needed
|
||||||
|
SocialMediaOptions = socialMediaOptions,
|
||||||
|
|
||||||
|
|
||||||
List<CheckBoxViewModel> selectListItems = new List<CheckBoxViewModel>();
|
// Map other properties from Footer to FooterUpdateViewModel as needed
|
||||||
|
|
||||||
foreach (var item in socialMedia)
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return View(footerViewModel);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IActionResult> Edit([Bind(include: "Id,Title,Name,Owner,Content,CreatedBy,UpdatedBy,LastUpdated,ImageUlr,Sitecopyright,SelectedSocialMediaIds,SocialMediaOptions")] FooterEditViewModel viewmodel)
|
||||||
{
|
{
|
||||||
selectListItems.Add(new CheckBoxViewModel
|
|
||||||
|
|
||||||
|
|
||||||
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
SocialMediaName=item.Name,
|
var footer = _footer.GetFooterByIdWithSocialMedia(viewmodel.Id);
|
||||||
SocialMediaId=item.Id,
|
|
||||||
IsSelected=false,
|
// Update other properties in the Footer model based on viewmodel
|
||||||
|
|
||||||
|
footer.Id = viewmodel.Id;
|
||||||
|
footer.Title = viewmodel.Title;
|
||||||
|
footer.Owner = viewmodel.Owner;
|
||||||
|
footer.Content = viewmodel.Content;
|
||||||
|
footer.Name = viewmodel.Name;
|
||||||
|
footer.LastUpdated = viewmodel.LastUpdated;
|
||||||
|
footer.UpdatedBy = viewmodel.UpdatedBy;
|
||||||
|
footer.CreatedBy = viewmodel.CreatedBy;
|
||||||
|
footer.Sitecopyright = viewmodel.Sitecopyright;
|
||||||
|
footer.ImageUlr = viewmodel.ImageUlr;
|
||||||
|
|
||||||
|
// Clear existing associations and add selected ones
|
||||||
|
//footer.FooterSocialMedias.Clear();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var selectedSocialMediaIds = viewmodel.SelectedSocialMediaIds ?? new List<int>();
|
||||||
|
|
||||||
|
var selectedSocialMedias = _socialMedia.GetSocialMedia()
|
||||||
|
.Where(sm => selectedSocialMediaIds.Contains(sm.Id))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var socialMedia in selectedSocialMedias)
|
||||||
|
{
|
||||||
|
|
||||||
|
footer.FooterSocialMedias.Add(new FooterSocialMedia
|
||||||
|
{
|
||||||
|
SocialId = socialMedia.Id
|
||||||
|
// Add other properties as needed
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return selectListItems;
|
|
||||||
|
_footer.Update(footer);
|
||||||
|
await _footer.commitAsync();
|
||||||
|
TempData["Success"] = "Footer updated successfully";
|
||||||
|
|
||||||
|
return RedirectToAction(nameof(Index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return View(viewmodel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Delete(int id)
|
||||||
|
{
|
||||||
|
|
||||||
|
var footer = _footer.GetFooterByIdWithSocialMedia(id);
|
||||||
|
|
||||||
|
var socialMediaOptions = _socialMedia.GetSocialMedia()
|
||||||
|
.Select(sm => new SelectListItem
|
||||||
|
{
|
||||||
|
Value = sm.Id.ToString(),
|
||||||
|
Text = sm.Name,
|
||||||
|
Selected = footer.FooterSocialMedias.Any(fsm => fsm.SocialId == sm.Id)
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var footerViewModel = new FooterDeleteViewModel
|
||||||
|
{
|
||||||
|
Id = footer.Id,
|
||||||
|
Title = footer.Title,
|
||||||
|
Name = footer.Name,
|
||||||
|
Owner = footer.Owner,
|
||||||
|
Content = footer.Content,
|
||||||
|
CreatedBy = footer.CreatedBy,
|
||||||
|
UpdatedBy = footer.UpdatedBy,
|
||||||
|
LastUpdated = footer.LastUpdated,
|
||||||
|
ImageUlr = footer.ImageUlr,
|
||||||
|
Sitecopyright = footer.Sitecopyright,
|
||||||
|
// Map other properties from Footer to FooterViewModel as needed
|
||||||
|
SocialMediaOptions = socialMediaOptions,
|
||||||
|
|
||||||
|
|
||||||
|
// Map other properties from Footer to FooterUpdateViewModel as needed
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return View(footerViewModel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[ActionName("Delete")]
|
||||||
|
public async Task<IActionResult> DeleteConfirm(int id)
|
||||||
|
{
|
||||||
|
|
||||||
|
_footer.Delete(id);
|
||||||
|
|
||||||
|
await _footer.commitAsync();
|
||||||
|
TempData["Success"] = "Footer deleted successfully";
|
||||||
|
|
||||||
|
return RedirectToAction(nameof(Index));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
81
Web/Areas/Admin/Controllers/QuestionnaireController.cs
Normal file
81
Web/Areas/Admin/Controllers/QuestionnaireController.cs
Normal file
|
|
@ -0,0 +1,81 @@
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
|
using Model;
|
||||||
|
using Services.Interaces;
|
||||||
|
using Web.ViewModel.QuestionnaireVM;
|
||||||
|
|
||||||
|
namespace Web.Areas.Admin.Controllers
|
||||||
|
{
|
||||||
|
public class QuestionnaireController : Controller
|
||||||
|
{
|
||||||
|
private readonly IQuestionnaireRepository _questionnaire;
|
||||||
|
|
||||||
|
public QuestionnaireController(IQuestionnaireRepository Questionnaire)
|
||||||
|
{
|
||||||
|
_questionnaire = Questionnaire;
|
||||||
|
}
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
|
||||||
|
var questionnaire = _questionnaire.GetQuestionnairesWithQuestion();
|
||||||
|
|
||||||
|
List<QuestionnaireViewModel> viewmodel = new List<QuestionnaireViewModel>();
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var item in questionnaire)
|
||||||
|
{
|
||||||
|
viewmodel.Add(new QuestionnaireViewModel
|
||||||
|
{
|
||||||
|
Id = item.Id,
|
||||||
|
Description = item.Description,
|
||||||
|
Title = item.Title,
|
||||||
|
Questions = item.Questions
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return View(viewmodel);
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Create()
|
||||||
|
{
|
||||||
|
|
||||||
|
var questionTypes = Enum.GetValues(typeof(QuestionType)).Cast<QuestionType>();
|
||||||
|
ViewBag.QuestionTypes = new SelectList(questionTypes);
|
||||||
|
var questionnaire = new QuestionnaireViewModel
|
||||||
|
{
|
||||||
|
Questions = new List<Question>()
|
||||||
|
};
|
||||||
|
|
||||||
|
return View(questionnaire);
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Create(QuestionnaireViewModel viewmodel)
|
||||||
|
{
|
||||||
|
if(ModelState.IsValid)
|
||||||
|
{
|
||||||
|
|
||||||
|
var questionnaire = new Questionnaire
|
||||||
|
{
|
||||||
|
Id = viewmodel.Id,
|
||||||
|
Title = viewmodel.Title,
|
||||||
|
Description = viewmodel.Description,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var item in viewmodel.Questions)
|
||||||
|
{
|
||||||
|
questionnaire.Questions.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
_questionnaire.Add(questionnaire);
|
||||||
|
|
||||||
|
_questionnaire.commitAsync();
|
||||||
|
|
||||||
|
|
||||||
|
return RedirectToAction(nameof(Index));
|
||||||
|
}
|
||||||
|
|
||||||
|
return View(viewmodel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -16,7 +16,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-striped ">
|
<table class="table table-responsive w-100 d-block d-md-table ">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
<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-striped ">
|
<table class="table table-responsive w-100 d-block d-md-table">
|
||||||
<thead>
|
<thead class="w-auto">
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<th scope="col">Id</th>
|
<th scope="col">Id</th>
|
||||||
|
|
@ -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 class="">
|
<tbody class="w-auto">
|
||||||
@foreach (var item in Model)
|
@foreach (var item in Model)
|
||||||
{
|
{
|
||||||
<tr class="table-secondary">
|
<tr class="table-secondary">
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<hr />
|
||||||
@*
|
@*
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Select Social Media:</legend>
|
<legend>Select Social Media:</legend>
|
||||||
|
|
|
||||||
175
Web/Areas/Admin/Views/Footer/Delete.cshtml
Normal file
175
Web/Areas/Admin/Views/Footer/Delete.cshtml
Normal file
|
|
@ -0,0 +1,175 @@
|
||||||
|
@model FooterDeleteViewModel
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Delete";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="container mt-4">
|
||||||
|
<div class="card justify-content-center">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">Delete banner</h5>
|
||||||
|
<h6 class="text-danger">Are you sure you want to delete the <span class="badge bg-danger">@Model.Title</span></h6>
|
||||||
|
|
||||||
|
<div class="row ">
|
||||||
|
<!-- 12 columns for textboxes -->
|
||||||
|
|
||||||
|
<form asp-action="Delete">
|
||||||
|
<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" disabled />
|
||||||
|
<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" disabled />
|
||||||
|
<span asp-validation-for="Name" 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" disabled />
|
||||||
|
<span asp-validation-for="Owner" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3 col-12">
|
||||||
|
<label asp-for="Content" class="control-label"></label>
|
||||||
|
<textarea asp-for="Content" disabled></textarea>
|
||||||
|
<span asp-validation-for="Content" 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" disabled />
|
||||||
|
<span asp-validation-for="UpdatedBy" 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" disabled />
|
||||||
|
<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" disabled />
|
||||||
|
<span asp-validation-for="LastUpdated" 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" disabled />
|
||||||
|
<span asp-validation-for="Sitecopyright" 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" disabled />
|
||||||
|
<span asp-validation-for="ImageUlr" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<fieldset>
|
||||||
|
<legend>Selected Social Media:</legend>
|
||||||
|
@foreach (var option in Model.SocialMediaOptions)
|
||||||
|
{
|
||||||
|
<input type="checkbox" name="SelectedSocialMediaIds" disabled value="@option.Value" @(option.Selected ? "checked" : "")>
|
||||||
|
@option.Text
|
||||||
|
<br>
|
||||||
|
}
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
|
||||||
|
</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 {
|
||||||
|
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/ckeditor/4.11.4/ckeditor.js"></script>
|
||||||
|
<script>
|
||||||
|
CKEDITOR.replace("Content");
|
||||||
|
</script>
|
||||||
|
@{
|
||||||
|
<partial name="_ValidationScriptsPartial" />
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Are you sure you want to delete @Model.Title</h3>
|
||||||
|
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h4>FooterDeleteViewModel</h4>
|
||||||
|
<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.Name)
|
||||||
|
</dt>
|
||||||
|
<dd class = "col-sm-10">
|
||||||
|
@Html.DisplayFor(model => model.Name)
|
||||||
|
</dd>
|
||||||
|
<dt class = "col-sm-2">
|
||||||
|
@Html.DisplayNameFor(model => model.Owner)
|
||||||
|
</dt>
|
||||||
|
<dd class = "col-sm-10">
|
||||||
|
@Html.DisplayFor(model => model.Owner)
|
||||||
|
</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.CreatedBy)
|
||||||
|
</dt>
|
||||||
|
<dd class = "col-sm-10">
|
||||||
|
@Html.DisplayFor(model => model.CreatedBy)
|
||||||
|
</dd>
|
||||||
|
<dt class = "col-sm-2">
|
||||||
|
@Html.DisplayNameFor(model => model.UpdatedBy)
|
||||||
|
</dt>
|
||||||
|
<dd class = "col-sm-10">
|
||||||
|
@Html.DisplayFor(model => model.UpdatedBy)
|
||||||
|
</dd>
|
||||||
|
<dt class = "col-sm-2">
|
||||||
|
@Html.DisplayNameFor(model => model.LastUpdated)
|
||||||
|
</dt>
|
||||||
|
<dd class = "col-sm-10">
|
||||||
|
@Html.DisplayFor(model => model.LastUpdated)
|
||||||
|
</dd>
|
||||||
|
<dt class = "col-sm-2">
|
||||||
|
@Html.DisplayNameFor(model => model.ImageUlr)
|
||||||
|
</dt>
|
||||||
|
<dd class = "col-sm-10">
|
||||||
|
@Html.DisplayFor(model => model.ImageUlr)
|
||||||
|
</dd>
|
||||||
|
<dt class = "col-sm-2">
|
||||||
|
@Html.DisplayNameFor(model => model.Sitecopyright)
|
||||||
|
</dt>
|
||||||
|
<dd class = "col-sm-10">
|
||||||
|
@Html.DisplayFor(model => model.Sitecopyright)
|
||||||
|
</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>
|
||||||
106
Web/Areas/Admin/Views/Footer/Edit.cshtml
Normal file
106
Web/Areas/Admin/Views/Footer/Edit.cshtml
Normal file
|
|
@ -0,0 +1,106 @@
|
||||||
|
@model FooterEditViewModel
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="container mt-4">
|
||||||
|
<div class="card justify-content-center">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">Update banner</h5>
|
||||||
|
|
||||||
|
<div class="row ">
|
||||||
|
<!-- 12 columns for textboxes -->
|
||||||
|
|
||||||
|
<form asp-action="Edit">
|
||||||
|
<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="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="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="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" @(option.Selected ? "checked" : "")>
|
||||||
|
@option.Text
|
||||||
|
<br>
|
||||||
|
}
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
|
||||||
|
</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 {
|
||||||
|
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/ckeditor/4.11.4/ckeditor.js"></script>
|
||||||
|
<script>
|
||||||
|
CKEDITOR.replace("Content");
|
||||||
|
</script>
|
||||||
|
@{
|
||||||
|
<partial name="_ValidationScriptsPartial" />
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -10,15 +10,15 @@
|
||||||
<partial name="_Notification" />
|
<partial name="_Notification" />
|
||||||
|
|
||||||
<div class="card bg-default mb-3 ">
|
<div class="card bg-default mb-3 ">
|
||||||
<div class="card-header">Address</div>
|
<div class="card-header">Footers</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h4 class="card-title">Address list</h4>
|
<h4 class="card-title">Footer list</h4>
|
||||||
<p>
|
<p>
|
||||||
<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-striped ">
|
<table class="table table-responsive w-100 d-block d-md-table">
|
||||||
<thead class="justify-content-center">
|
<thead class="w-auto">
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<th scope="col">Id</th>
|
<th scope="col">Id</th>
|
||||||
|
|
@ -32,7 +32,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 class="justify-content-center">
|
<tbody class="w-auto">
|
||||||
@foreach (var item in Model)
|
@foreach (var item in Model)
|
||||||
{
|
{
|
||||||
<tr class=" table-secondary">
|
<tr class=" table-secondary">
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
@foreach (var option in item.SocialMediaOptions)
|
@foreach (var option in item.SocialMediaOptions)
|
||||||
{
|
{
|
||||||
<input type="checkbox" name="SelectedSocialMediaIds" value="@option.Value" disabled
|
<input type="checkbox" name="SelectedSocialMediaIds" value="@option.Value" disabled
|
||||||
@(item.SelectedSocialMediaIds != null && item.SelectedSocialMediaIds.Contains(int.Parse(option.Value)) ? "checked" : "unchecked")>
|
@(item.SelectedSocialMediaIds != null && item.SelectedSocialMediaIds.Contains(int.Parse(option.Value)) ? "checked":"")>
|
||||||
@option.Text
|
@option.Text
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
|
||||||
108
Web/Areas/Admin/Views/Questionnaire/Create.cshtml
Normal file
108
Web/Areas/Admin/Views/Questionnaire/Create.cshtml
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
@model Web.ViewModel.QuestionnaireVM.QuestionnaireViewModel
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Create";
|
||||||
|
}
|
||||||
|
<div class="container mt-4">
|
||||||
|
<div class="card justify-content-center">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">Create Survey</h5>
|
||||||
|
|
||||||
|
<div class="row ">
|
||||||
|
<!-- 12 columns for textboxes -->
|
||||||
|
|
||||||
|
<form asp-action="Create" asp-controller="Questionnaire">
|
||||||
|
<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="Description" class="control-label"></label>
|
||||||
|
<input asp-for="Description" class="form-control" />
|
||||||
|
<span asp-validation-for="Description" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<div id="questions-container">
|
||||||
|
<h3>Create Questions</h3>
|
||||||
|
<div class="form-group">
|
||||||
|
@for (int i = 0; i < Model.Questions?.Count; i++)
|
||||||
|
{
|
||||||
|
<div class="question-group">
|
||||||
|
<label>Question @(i + 1)</label>
|
||||||
|
<textarea name="Questions[@i].Text" class="form-control">@Model.Questions[i].Text</textarea>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<div class="mt-5">
|
||||||
|
|
||||||
|
<select name="Questions[@i].Type" class="form-control question-type">
|
||||||
|
|
||||||
|
<option value="">Select Question Type</option>
|
||||||
|
@foreach (var questionType in ViewBag.QuestionTypes)
|
||||||
|
{
|
||||||
|
<option value="@questionType.Value">@questionType.Text</option>
|
||||||
|
<option value="">Select Question Type</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<button type="button" class="btn btn-primary" id="add-question">Add Question</button> |
|
||||||
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
|
| <a asp-action="Index" class="btn btn-info">Back to list</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@section Scripts {
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/ckeditor/4.11.4/ckeditor.js"></script>
|
||||||
|
<script>
|
||||||
|
CKEDITOR.replace("Questions");
|
||||||
|
</script>
|
||||||
|
@{
|
||||||
|
<partial name="_ValidationScriptsPartial" />
|
||||||
|
}
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
var questionCounter = @Model.Questions?.Count;
|
||||||
|
|
||||||
|
$("#add-question").on("click", function () {
|
||||||
|
var newQuestionHtml = '<div class="form-group">' +
|
||||||
|
'<label>Question ' + (++questionCounter) + '</label>' +
|
||||||
|
'<textarea type="text" name="Questions[' + questionCounter + '].Text" class="form-control"></textarea>' +'<br>' +
|
||||||
|
'<select name="Questions[' + questionCounter + '].Type" class="form-control">';
|
||||||
|
|
||||||
|
newQuestionHtml += '<option value="">Select Question Type</option>';
|
||||||
|
|
||||||
|
|
||||||
|
@foreach (var questionType in ViewBag.QuestionTypes)
|
||||||
|
{
|
||||||
|
@:newQuestionHtml += '<option value="@questionType.Value">@questionType.Text</option>';
|
||||||
|
}
|
||||||
|
|
||||||
|
newQuestionHtml += '</select></div>';
|
||||||
|
|
||||||
|
$("#questions-container").append(newQuestionHtml);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
}
|
||||||
47
Web/Areas/Admin/Views/Questionnaire/Index.cshtml
Normal file
47
Web/Areas/Admin/Views/Questionnaire/Index.cshtml
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
@model IEnumerable<Web.ViewModel.QuestionnaireVM.QuestionnaireViewModel>
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Index";
|
||||||
|
}
|
||||||
|
|
||||||
|
<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.Description)
|
||||||
|
</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.Description)
|
||||||
|
</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>
|
||||||
|
|
@ -35,6 +35,10 @@
|
||||||
<li>
|
<li>
|
||||||
<a asp-controller="SocialMedia" asp-action="index"><span class="bi bi-collection-play-fill"></span> Social Media</a>
|
<a asp-controller="SocialMedia" asp-action="index"><span class="bi bi-collection-play-fill"></span> Social Media</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<a asp-controller="Questionnaire" asp-action="index"><span class="bi bi-question-circle"></span> Survey</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
<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-striped ">
|
<table class="table table-responsive w-100 d-block d-md-table">
|
||||||
<thead>
|
<thead class="w-auto">
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<th scope="col">Id</th>
|
<th scope="col">Id</th>
|
||||||
|
|
@ -27,7 +27,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 class="justify-content-center">
|
<tbody class="w-auto">
|
||||||
@foreach (var item in Model)
|
@foreach (var item in Model)
|
||||||
{
|
{
|
||||||
<tr class="table-secondary">
|
<tr class="table-secondary">
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,5 @@
|
||||||
@using Web.ViewModel.BannerVM
|
@using Web.ViewModel.BannerVM
|
||||||
@using Web.ViewModel.FooterVm
|
@using Web.ViewModel.FooterVm
|
||||||
@using Web.ViewModel.SocialMediaVM
|
@using Web.ViewModel.SocialMediaVM
|
||||||
|
@using Web.ViewModel.QuestionnaireVM
|
||||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
|
|
|
||||||
|
|
@ -38,5 +38,9 @@ namespace Web.Extesions
|
||||||
{
|
{
|
||||||
services.AddScoped<IFooterRepository, FooterRepository>();
|
services.AddScoped<IFooterRepository, FooterRepository>();
|
||||||
}
|
}
|
||||||
|
public static void ConfigureQuestionnarie(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddScoped<IQuestionnaireRepository, QuestionnaireRepository>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
371
Web/Migrations/20240307153635_SurveyModelsAdded.Designer.cs
generated
Normal file
371
Web/Migrations/20240307153635_SurveyModelsAdded.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,371 @@
|
||||||
|
// <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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
108
Web/Migrations/20240307153635_SurveyModelsAdded.cs
Normal file
108
Web/Migrations/20240307153635_SurveyModelsAdded.cs
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -65,6 +65,27 @@ namespace Web.Migrations
|
||||||
b.ToTable("Addresss");
|
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 =>
|
modelBuilder.Entity("Model.Banner", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
|
|
@ -190,6 +211,65 @@ namespace Web.Migrations
|
||||||
b.ToTable("Pages");
|
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 =>
|
modelBuilder.Entity("Model.SocialMedia", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
|
|
@ -211,6 +291,17 @@ namespace Web.Migrations
|
||||||
b.ToTable("SocialMedia");
|
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 =>
|
modelBuilder.Entity("Model.FooterSocialMedia", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Model.Footer", "Footer")
|
b.HasOne("Model.Footer", "Footer")
|
||||||
|
|
@ -241,11 +332,32 @@ namespace Web.Migrations
|
||||||
b.Navigation("banner");
|
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 =>
|
modelBuilder.Entity("Model.Footer", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("FooterSocialMedias");
|
b.Navigation("FooterSocialMedias");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Model.Question", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Answers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Model.Questionnaire", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Questions");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Model.SocialMedia", b =>
|
modelBuilder.Entity("Model.SocialMedia", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("FooterSocialMedias");
|
b.Navigation("FooterSocialMedias");
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using Data;
|
||||||
using Microsoft.AspNetCore.Mvc.Razor;
|
using Microsoft.AspNetCore.Mvc.Razor;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Services.Implemnetation;
|
using Services.Implemnetation;
|
||||||
|
|
@ -17,7 +18,8 @@ builder.Services.ConfigureBannerServices();
|
||||||
builder.Services.ConfigureAddress();
|
builder.Services.ConfigureAddress();
|
||||||
builder.Services.ConfigureSocialMedia();
|
builder.Services.ConfigureSocialMedia();
|
||||||
builder.Services.ConfigureFooter();
|
builder.Services.ConfigureFooter();
|
||||||
|
builder.Services.ConfigureQuestionnarie();
|
||||||
|
//builder.Services.AddScoped<SurveyContext>();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
|
|
||||||
43
Web/ViewModel/FooterVm/FooterDeleteViewModel.cs
Normal file
43
Web/ViewModel/FooterVm/FooterDeleteViewModel.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace Web.ViewModel.FooterVm
|
||||||
|
{
|
||||||
|
public class FooterDeleteViewModel
|
||||||
|
{
|
||||||
|
public FooterDeleteViewModel()
|
||||||
|
{
|
||||||
|
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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
43
Web/ViewModel/FooterVm/FooterEditViewModel.cs
Normal file
43
Web/ViewModel/FooterVm/FooterEditViewModel.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace Web.ViewModel.FooterVm
|
||||||
|
{
|
||||||
|
public class FooterEditViewModel
|
||||||
|
{
|
||||||
|
public FooterEditViewModel()
|
||||||
|
{
|
||||||
|
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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -8,10 +8,10 @@ namespace Web.ViewModel.FooterVm
|
||||||
{
|
{
|
||||||
public class InserFooterViewModel
|
public class InserFooterViewModel
|
||||||
{
|
{
|
||||||
//public InserFooterViewModel()
|
public InserFooterViewModel()
|
||||||
//{
|
{
|
||||||
// SocialMediaOptions = new List<SelectListItem>();
|
SocialMediaOptions = new List<SelectListItem>();
|
||||||
//}
|
}
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public string? Title { get; set; }
|
public string? Title { get; set; }
|
||||||
|
|
|
||||||
19
Web/ViewModel/QuestionnaireVM/QuestionnaireViewModel.cs
Normal file
19
Web/ViewModel/QuestionnaireVM/QuestionnaireViewModel.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
using Model;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Web.ViewModel.QuestionnaireVM
|
||||||
|
{
|
||||||
|
public class QuestionnaireViewModel
|
||||||
|
{
|
||||||
|
public QuestionnaireViewModel()
|
||||||
|
{
|
||||||
|
Questions = new List<Question>();
|
||||||
|
}
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string? Title { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string? Description { get; set; }
|
||||||
|
public List<Question>? Questions { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -35,6 +35,11 @@
|
||||||
--font-family-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
--font-family-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.question-group {
|
||||||
|
margin-bottom: 20px; /* Adjust the value to control the spacing */
|
||||||
|
}
|
||||||
|
|
||||||
*,
|
*,
|
||||||
*::before,
|
*::before,
|
||||||
*::after {
|
*::after {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue