School Commit Init

This commit is contained in:
2024-08-31 12:07:21 +03:00
commit 0b130ee18c
2801 changed files with 4720552 additions and 0 deletions
@@ -0,0 +1,109 @@
using Microsoft.EntityFrameworkCore;
using ProfessionalProfile.DatabaseContext;
using ProfessionalProfile.Domain;
using ProfessionalProfile.Interfaces;
namespace ProfessionalProfile.repo
{
public class AnswerRepo : IAnswerRepo
{
private readonly IDbContextFactory<DataContext> _contextFactory;
public AnswerRepo(IDbContextFactory<DataContext> contextFactory)
{
_contextFactory = contextFactory;
}
public void Add(Answer item)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
context.Answers.Add(item);
context.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
}
public void Delete(int id)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
var answer = context.Answers.Find(id);
context.Answers.Remove(answer);
context.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
}
public ICollection<Answer> GetAll()
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Answers.ToList();
}
}
catch (Exception ex)
{
throw ex;
}
}
public Answer GetById(int id)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Answers.Find(id);
}
}
catch (Exception ex)
{
throw ex;
}
}
public void Update(Answer answer)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
context.Answers.Update(answer);
context.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
}
public ICollection<Answer> GetAnswers(int QuestionId)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Answers.Where(x => x.questionId == QuestionId).ToList();
}
}
catch (Exception ex)
{
throw ex;
}
}
}
}
@@ -0,0 +1,110 @@
using Microsoft.EntityFrameworkCore;
using ProfessionalProfile.DatabaseContext;
using ProfessionalProfile.Domain;
using ProfessionalProfile.Interfaces;
namespace ProfessionalProfile.repo
{
public class AssessmentResultRepo : IAssessmentResultRepo
{
private readonly IDbContextFactory<DataContext> _contextFactory;
public AssessmentResultRepo(IDbContextFactory<DataContext> contextFactory)
{
_contextFactory = contextFactory;
}
public void Add(AssessmentResult item)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
context.AssessmentResult.Add(item);
context.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
}
public void Delete(int id)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
var assessmentResult = context.AssessmentResult.Find(id);
context.AssessmentResult.Remove(assessmentResult);
context.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
}
public ICollection<AssessmentResult> GetAll()
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
return context.AssessmentResult.ToList();
}
}
catch (Exception ex)
{
throw ex;
}
}
public AssessmentResult GetById(int id)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
return context.AssessmentResult.Find(id);
}
}
catch (Exception ex)
{
throw ex;
}
}
public void Update(AssessmentResult assessmentResult)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
context.AssessmentResult.Update(assessmentResult);
context.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
}
public ICollection<AssessmentResult> GetAssessmentResultsByUserId(int userId)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
return context.AssessmentResult.Where(x => x.userId == userId).ToList();
}
}
catch (Exception ex)
{
throw ex;
}
}
}
}
@@ -0,0 +1,66 @@
using Microsoft.EntityFrameworkCore;
using ProfessionalProfile.DatabaseContext;
using ProfessionalProfile.Domain;
using ProfessionalProfile.Interfaces;
namespace ProfessionalProfile.repo
{
public class AssessmentTestRepo : IAssessmentTestRepo
{
private readonly IDbContextFactory<DataContext> _contextFactory;
public AssessmentTestRepo(IDbContextFactory<DataContext> contextFactory)
{
_contextFactory = contextFactory;
}
public void Add(AssessmentTest item)
{
using (var context = _contextFactory.CreateDbContext())
{
context.AssessmentTest.Add(item);
context.SaveChanges();
}
}
public void Delete(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
var assessmentTest = context.AssessmentTest.Find(id);
context.AssessmentTest.Remove(assessmentTest);
context.SaveChanges();
}
}
public ICollection<AssessmentTest> GetAll()
{
using (var context = _contextFactory.CreateDbContext())
{
return context.AssessmentTest.ToList();
}
}
public AssessmentTest GetById(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
return context.AssessmentTest.Find(id);
}
}
public void Update(AssessmentTest assessmentTest)
{
using (var context = _contextFactory.CreateDbContext())
{
context.AssessmentTest.Update(assessmentTest);
context.SaveChanges();
}
}
public int GetIdByName(string testName)
{
using (var context = _contextFactory.CreateDbContext())
{
return context.AssessmentTest.Where(x => x.testName == testName).Select(x => x.assessmentTestId).FirstOrDefault();
}
}
}
}
@@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore;
using ProfessionalProfile.DatabaseContext;
using ProfessionalProfile.Domain;
using ProfessionalProfile.Interfaces;
namespace ProfessionalProfile.repo
{
public class BusinessCardRepo : IBusinessCardRepo
{
private readonly IDbContextFactory<DataContext> _contextFactory;
public BusinessCardRepo(IDbContextFactory<DataContext> contextFactory)
{
_contextFactory = contextFactory;
}
public void Add(BusinessCard item)
{
using (var context = _contextFactory.CreateDbContext())
{
context.BusinessCard.Add(item);
context.SaveChanges();
}
}
public void Delete(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
var businessCard = context.BusinessCard.Find(id);
context.BusinessCard.Remove(businessCard);
context.SaveChanges();
}
}
public ICollection<BusinessCard> GetAll()
{
using (var context = _contextFactory.CreateDbContext())
{
return context.BusinessCard.ToList();
}
}
public BusinessCard GetById(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
return context.BusinessCard.Find(id);
}
}
public void Update(BusinessCard businessCard)
{
using (var context = _contextFactory.CreateDbContext())
{
context.BusinessCard.Update(businessCard);
context.SaveChanges();
}
}
}
}
@@ -0,0 +1,99 @@
using Microsoft.EntityFrameworkCore;
using ProfessionalProfile.DatabaseContext;
using ProfessionalProfile.Domain;
using ProfessionalProfile.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
namespace ProfessionalProfile.repo
{
public class CertificateRepo : ICertificateRepo
{
private readonly IDbContextFactory<DataContext> _contextFactory;
public CertificateRepo(IDbContextFactory<DataContext> contextFactory)
{
_contextFactory = contextFactory;
}
public void Add(Certificate item)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
context.Certificate.Add(item);
context.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
}
public void Delete(int id)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
var certificate = context.Certificate.Find(id);
context.Certificate.Remove(certificate);
context.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
}
public ICollection<Certificate> GetAll()
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Certificate.ToList();
}
}
catch (Exception ex)
{
throw ex;
}
}
public Certificate GetById(int id)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Certificate.Find(id);
}
}
catch (Exception ex)
{
throw ex;
}
}
public void Update(Certificate certificate)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
context.Certificate.Update(certificate);
context.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
}
}
}
@@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore;
using ProfessionalProfile.DatabaseContext;
using ProfessionalProfile.Domain;
using ProfessionalProfile.Interfaces;
namespace ProfessionalProfile.repo
{
public class EducationRepo : IEducationRepo
{
private readonly IDbContextFactory<DataContext> _contextFactory;
public EducationRepo(IDbContextFactory<DataContext> contextFactory)
{
_contextFactory = contextFactory;
}
public void Add(Education item)
{
using (var context = _contextFactory.CreateDbContext())
{
context.Education.Add(item);
context.SaveChanges();
}
}
public void Delete(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
var education = context.Education.Find(id);
context.Education.Remove(education);
context.SaveChanges();
}
}
public ICollection<Education> GetAll()
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Education.ToList();
}
}
public Education GetById(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Education.Find(id);
}
}
public void Update(Education education)
{
using (var context = _contextFactory.CreateDbContext())
{
context.Education.Update(education);
context.SaveChanges();
}
}
}
}
@@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore;
using ProfessionalProfile.DatabaseContext;
using ProfessionalProfile.Domain;
using ProfessionalProfile.Interfaces;
namespace ProfessionalProfile.repo
{
public class EndorsementRepo : IEndorsementRepo
{
private readonly IDbContextFactory<DataContext> _contextFactory;
public EndorsementRepo(IDbContextFactory<DataContext> contextFactory)
{
_contextFactory = contextFactory;
}
public void Add(Endorsement item)
{
using (var context = _contextFactory.CreateDbContext())
{
context.Endorsement.Add(item);
context.SaveChanges();
}
}
public void Delete(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
var endorsement = context.Endorsement.Find(id);
context.Endorsement.Remove(endorsement);
context.SaveChanges();
}
}
public ICollection<Endorsement> GetAll()
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Endorsement.ToList();
}
}
public Endorsement GetById(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Endorsement.Find(id);
}
}
public void Update(Endorsement endorsement)
{
using (var context = _contextFactory.CreateDbContext())
{
context.Endorsement.Update(endorsement);
context.SaveChanges();
}
}
}
}
@@ -0,0 +1,68 @@
using Microsoft.EntityFrameworkCore;
using ProfessionalProfile.DatabaseContext;
using ProfessionalProfile.Domain;
using ProfessionalProfile.Interfaces;
namespace ProfessionalProfile.repo
{
public class NotificationRepo : INotificationRepo
{
private readonly IDbContextFactory<DataContext> _contextFactory;
public NotificationRepo(IDbContextFactory<DataContext> contextFactory)
{
_contextFactory = contextFactory;
}
public void Add(Notification item)
{
using (var context = _contextFactory.CreateDbContext())
{
context.Notification.Add(item);
context.SaveChanges();
}
}
public void Delete(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
var notification = context.Notification.Find(id);
context.Notification.Remove(notification);
context.SaveChanges();
}
}
public ICollection<Notification> GetAll()
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Notification.ToList();
}
}
public Notification GetById(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Notification.Find(id);
}
}
public void Update(Notification notification)
{
using (var context = _contextFactory.CreateDbContext())
{
context.Notification.Update(notification);
context.SaveChanges();
}
}
// List<Notification> ProfessionalProfile.Interfaces.INotificationRepo.GetAllByUserId(int)' is not implemented
public List<Notification> GetAllByUserId(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Notification.Where(n => n.userId == id).ToList();
}
}
}
}
@@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore;
using ProfessionalProfile.DatabaseContext;
using ProfessionalProfile.Domain;
using ProfessionalProfile.Interfaces;
namespace ProfessionalProfile.repo
{
public class PrivacyRepo : IPrivacyRepo
{
private readonly IDbContextFactory<DataContext> _contextFactory;
public PrivacyRepo(IDbContextFactory<DataContext> contextFactory)
{
_contextFactory = contextFactory;
}
public void Add(Privacy item)
{
using (var context = _contextFactory.CreateDbContext())
{
context.Privacy.Add(item);
context.SaveChanges();
}
}
public void Delete(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
var privacy = context.Privacy.Find(id);
context.Privacy.Remove(privacy);
context.SaveChanges();
}
}
public ICollection<Privacy> GetAll()
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Privacy.ToList();
}
}
public Privacy GetById(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Privacy.Find(id);
}
}
public void Update(Privacy privacy)
{
using (var context = _contextFactory.CreateDbContext())
{
context.Privacy.Update(privacy);
context.SaveChanges();
}
}
}
}
@@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore;
using ProfessionalProfile.DatabaseContext;
using ProfessionalProfile.Domain;
using ProfessionalProfile.Interfaces;
namespace ProfessionalProfile.repo
{
public class ProjectRepo : IProjectRepo
{
private readonly IDbContextFactory<DataContext> _contextFactory;
public ProjectRepo(IDbContextFactory<DataContext> contextFactory)
{
_contextFactory = contextFactory;
}
public void Add(Project item)
{
using (var context = _contextFactory.CreateDbContext())
{
context.Project.Add(item);
context.SaveChanges();
}
}
public void Delete(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
var project = context.Project.Find(id);
context.Project.Remove(project);
context.SaveChanges();
}
}
public ICollection<Project> GetAll()
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Project.ToList();
}
}
public Project GetById(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Project.Find(id);
}
}
public void Update(Project project)
{
using (var context = _contextFactory.CreateDbContext())
{
context.Project.Update(project);
context.SaveChanges();
}
}
}
}
@@ -0,0 +1,76 @@
using Microsoft.EntityFrameworkCore;
using ProfessionalProfile.DatabaseContext;
using ProfessionalProfile.Domain;
using ProfessionalProfile.Interfaces;
namespace ProfessionalProfile.repo
{
public class QuestionRepo : IQuestionRepo
{
private readonly IDbContextFactory<DataContext> _contextFactory;
public QuestionRepo(IDbContextFactory<DataContext> contextFactory)
{
_contextFactory = contextFactory;
}
public void Add(Question item)
{
using (var context = _contextFactory.CreateDbContext())
{
context.Question.Add(item);
context.SaveChanges();
}
}
public void Delete(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
var question = context.Question.Find(id);
context.Question.Remove(question);
context.SaveChanges();
}
}
public ICollection<Question> GetAll()
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Question.ToList();
}
}
public Question GetById(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Question.Find(id);
}
}
public void Update(Question question)
{
using (var context = _contextFactory.CreateDbContext())
{
context.Question.Update(question);
context.SaveChanges();
}
}
//Interface member 'List<Question> ProfessionalProfile.Interfaces.IQuestionRepo.GetAllByTestId(int)' is not implemented
//Interface member 'int ProfessionalProfile.Interfaces.IQuestionRepo.GetIdByNameAndAssessmentId(string, int)' is not implemented
public List<Question> GetAllByTestId(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Question.Where(x => x.assesmentTestId == id).ToList();
}
}
public int GetIdByNameAndAssessmentId(string question, int assessmentId)
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Question.Where(x => x.questionText == question && x.assesmentTestId == assessmentId).Select(x => x.questionId).FirstOrDefault();
}
}
}
}
@@ -0,0 +1,122 @@
using Microsoft.EntityFrameworkCore;
using ProfessionalProfile.DatabaseContext;
using ProfessionalProfile.Domain;
using ProfessionalProfile.Interfaces;
namespace ProfessionalProfile.repo
{
public class SkillRepo : ISkillRepo
{
private readonly IDbContextFactory<DataContext> _contextFactory;
public SkillRepo(IDbContextFactory<DataContext> contextFactory)
{
_contextFactory = contextFactory;
}
public void Add(Skill item)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
context.Skill.Add(item);
context.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
}
public void Delete(int id)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
var item = context.Skill.Find(id);
context.Skill.Remove(item);
context.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
}
public ICollection<Skill> GetAll()
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Skill.ToList();
}
}
catch (Exception ex)
{
throw ex;
}
}
public Skill GetById(int id)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Skill.Find(id);
}
}
catch (Exception ex)
{
throw ex;
}
}
public List<Skill> GetByUserId(int userId)
{
try
{
throw new NotImplementedException();
}
catch (Exception ex)
{
throw ex;
}
}
public int GetIdByName(string name)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Skill.Where(x => x.name == name).FirstOrDefault().skillId;
}
}
catch (Exception ex)
{
throw ex;
}
}
public void Update(Skill item)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
context.Skill.Update(item);
context.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
}
}
}
@@ -0,0 +1,102 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using ProfessionalProfile.DatabaseContext;
using ProfessionalProfile.Domain;
using ProfessionalProfile.Interfaces;
namespace ProfessionalProfile.Repo
{
public class UserRepo : IUserRepoInterface
{
private readonly IDbContextFactory<DataContext> _contextFactory;
public UserRepo(IDbContextFactory<DataContext> contextFactory)
{
_contextFactory = contextFactory;
}
public void Add(User item)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
context.User.Add(item);
context.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
}
public void Delete(int id)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
var user = context.User.Find(id);
context.User.Remove(user);
context.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
}
public ICollection<User> GetAll()
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
return context.User.ToList();
}
}
catch (Exception ex)
{
throw ex;
}
}
public User GetById(int id)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
return context.User.Find(id);
}
}
catch (Exception ex)
{
throw ex;
}
}
public void Update(User user)
{
try
{
using (var context = _contextFactory.CreateDbContext())
{
context.User.Update(user);
context.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
}
}
}
@@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore;
using ProfessionalProfile.DatabaseContext;
using ProfessionalProfile.Domain;
using ProfessionalProfile.Interfaces;
namespace ProfessionalProfile.repo
{
public class VolunteeringRepo : IVolunteeringRepo
{
private readonly IDbContextFactory<DataContext> _contextFactory;
public VolunteeringRepo(IDbContextFactory<DataContext> contextFactory)
{
_contextFactory = contextFactory;
}
public void Add(Volunteering item)
{
using (var context = _contextFactory.CreateDbContext())
{
context.Volunteering.Add(item);
context.SaveChanges();
}
}
public void Delete(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
var volunteering = context.Volunteering.Find(id);
context.Volunteering.Remove(volunteering);
context.SaveChanges();
}
}
public ICollection<Volunteering> GetAll()
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Volunteering.ToList();
}
}
public Volunteering GetById(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
return context.Volunteering.Find(id);
}
}
public void Update(Volunteering volunteering)
{
using (var context = _contextFactory.CreateDbContext())
{
context.Volunteering.Update(volunteering);
context.SaveChanges();
}
}
}
}
@@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore;
using ProfessionalProfile.DatabaseContext;
using ProfessionalProfile.Domain;
using ProfessionalProfile.Interfaces;
namespace ProfessionalProfile.repo
{
public class WorkExperienceRepo : IWorkExperienceRepo
{
private readonly IDbContextFactory<DataContext> _contextFactory;
public WorkExperienceRepo(IDbContextFactory<DataContext> contextFactory)
{
_contextFactory = contextFactory;
}
public void Add(WorkExperience item)
{
using (var context = _contextFactory.CreateDbContext())
{
context.WorkExperience.Add(item);
context.SaveChanges();
}
}
public void Delete(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
var workExperience = context.WorkExperience.Find(id);
context.WorkExperience.Remove(workExperience);
context.SaveChanges();
}
}
public ICollection<WorkExperience> GetAll()
{
using (var context = _contextFactory.CreateDbContext())
{
return context.WorkExperience.ToList();
}
}
public WorkExperience GetById(int id)
{
using (var context = _contextFactory.CreateDbContext())
{
return context.WorkExperience.Find(id);
}
}
public void Update(WorkExperience workExperience)
{
using (var context = _contextFactory.CreateDbContext())
{
context.WorkExperience.Update(workExperience);
context.SaveChanges();
}
}
}
}