Доделал свою часть, стореджи не до конца

This commit is contained in:
GokaPek 2024-04-19 19:30:16 +04:00
parent 4b0110e728
commit 516d109b03
38 changed files with 848 additions and 15 deletions

View File

@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using UniversityDataModels.Models;
namespace UniversityContracts.BindingModel
namespace UniversityContracts.BindingModels
{
public class AttestationBindingModel : IAttestationModel
{

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityDataModels.Models;
namespace UniversityContracts.BindingModels
{
public class DisciplineBindingModel : IDisciplineModel
{
public int Id { get; set; }
public int TeacherId { get; set; }
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
}
}

View File

@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using UniversityDataModels.Models;
namespace UniversityContracts.BindingModel
namespace UniversityContracts.BindingModels
{
public class PlanOfStudyBindingModel : IPlanOfStudyModel
{

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityDataModels.Models;
namespace UniversityContracts.BindingModels
{
public class StatementBindingModel : IStatementModel
{
public int Id { get; set; }
public int TeacherId { get; set; }
public string Name { get; set; } = string.Empty;
public DateTime Date { get; }
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityDataModels.Models;
namespace UniversityContracts.BindingModels
{
public class StorekeeperBindingModel : IStorekeeperModel
{
public int Id { get; set; }
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public string MiddleName { get; set; } = string.Empty;
public string PhoneNumber { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
}
}

View File

@ -1,6 +1,6 @@
using UniversityDataModels.Models;
namespace UniversityContracts.BindingModel
namespace UniversityContracts.BindingModels
{
public class StudentBindingModel : IStudentModel
{

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityDataModels.Models;
namespace UniversityContracts.BindingModels
{
public class TeacherBindingModel : ITeacherModel
{
public int Id { get; set; }
public int StorekeeperId { get; set; }
public string Name { get; set; } = string.Empty;
public string AcademicDegree { get; set; } = string.Empty;
public string Position { get; set; } = string.Empty;
}
}

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModel;
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;

View File

@ -0,0 +1,15 @@
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
namespace UniversityContracts.BusinessLogicsContracts
{
public interface IDisciplineLogic
{
List<DisciplineViewModel>? ReadList(DisciplineSearchModel? model);
DisciplineViewModel? ReadElement(DisciplineSearchModel model);
bool Create(DisciplineBindingModel model);
bool Update(DisciplineBindingModel model);
bool Delete(DisciplineBindingModel model);
}
}

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModel;
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;

View File

@ -0,0 +1,15 @@
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
namespace UniversityContracts.BusinessLogicsContracts
{
public interface IStatementLogic
{
List<StatementViewModel>? ReadList(StatementSearchModel? model);
StatementViewModel? ReadElement(StatementSearchModel model);
bool Create(StatementBindingModel model);
bool Update(StatementBindingModel model);
bool Delete(StatementBindingModel model);
}
}

View File

@ -1,4 +1,4 @@
using UniversityContracts.BindingModel;
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;

View File

@ -0,0 +1,15 @@
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
namespace UniversityContracts.BusinessLogicsContracts
{
public interface ITeacherLogic
{
List<TeacherViewModel>? ReadList(TeacherSearchModel? model);
TeacherViewModel? ReadElement(TeacherSearchModel model);
bool Create(TeacherBindingModel model);
bool Update(TeacherBindingModel model);
bool Delete(TeacherBindingModel model);
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UniversityContracts.SearchModels
{
public class DisciplineSearchModel
{
public int? TeacherId { get; set; }
public string? Name { get; set; }
public string? Description { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UniversityContracts.SearchModels
{
public class StatementSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
public DateTime? Date { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UniversityContracts.SearchModels
{
public class TeacherSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
public string? AcademicDegree { get; set; }
public string? Position { get; set; }
}
}

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModel;
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
namespace UniversityContracts.StorageContracts
{
public interface IDisciplineStorage
{
List<DisciplineViewModel> GetFullList();
List<DisciplineViewModel> GetFilteredList(DisciplineSearchModel model);
DisciplineViewModel? GetElement(DisciplineSearchModel model);
DisciplineViewModel? Insert(DisciplineBindingModel model);
DisciplineViewModel? Update(DisciplineBindingModel model);
DisciplineViewModel? Delete(DisciplineBindingModel model);
}
}

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModel;
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
namespace UniversityContracts.StorageContracts
{
public interface IStatementStorage
{
List<StatementViewModel> GetFullList();
List<StatementViewModel> GetFilteredList(StatementSearchModel model);
StatementViewModel? GetElement(StatementSearchModel model);
StatementViewModel? Insert(StatementBindingModel model);
StatementViewModel? Update(StatementBindingModel model);
StatementViewModel? Delete(StatementBindingModel model);
}
}

View File

@ -1,4 +1,4 @@
using UniversityContracts.BindingModel;
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
namespace UniversityContracts.StorageContracts
{
public interface ITeacherStorage
{
List<TeacherViewModel> GetFullList();
List<TeacherViewModel> GetFilteredList(TeacherSearchModel model);
TeacherViewModel? GetElement(TeacherSearchModel model);
TeacherViewModel? Insert(TeacherBindingModel model);
TeacherViewModel? Update(TeacherBindingModel model);
TeacherViewModel? Delete(TeacherBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityDataModels.Models;
namespace UniversityContracts.ViewModels
{
public class DisciplineViewModel : IDisciplineModel
{
public int Id { get; set; }
public int TeacherId { get; set; }
[DisplayName("Название дисциплины")]
public string Name { get; set; } = string.Empty;
[DisplayName("Описание дисциплины")]
public string Description { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityDataModels.Models;
namespace UniversityContracts.ViewModels
{
public class StatementViewModel : IStatementModel
{
public int Id { get; set; }
public int TeacherId { get; set; }
[DisplayName("Название ведомости")]
public string Name { get; set; } = string.Empty;
[DisplayName("Дата оформления ведомости")]
public DateTime Date { get; set; }
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityDataModels.Models;
namespace UniversityContracts.ViewModels
{
public class StorekeeperViewModel : IStorekeeperModel
{
public int Id { get; set; }
[DisplayName("Имя")]
public string FirstName { get; set; } = string.Empty;
[DisplayName("Фамилия")]
public string LastName { get; set; } = string.Empty;
[DisplayName("Отчество")]
public string MiddleName { get; set; } = string.Empty;
[DisplayName("Номер телефона")]
public string PhoneNumber { get; set; } = string.Empty;
[DisplayName("Почта")]
public string Email { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityDataModels.Models;
namespace UniversityContracts.ViewModels
{
public class TeacherViewModel : ITeacherModel
{
public int Id { get; set; }
public int StorekeeperId { get; set; }
[DisplayName("ФИО")]
public string Name { get; set; } = string.Empty;
[DisplayName("Учёная степень")]
public string AcademicDegree { get; set; } = string.Empty;
[DisplayName("Должность")]
public string Position { get; set; } = string.Empty;
}
}

View File

@ -3,7 +3,7 @@
public interface IDisciplineModel : IId
{
int TeacherId { get; }
string Name { get; set; }
string Description { get; set; }
string Name { get; }
string Description { get; }
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UniversityDatabaseImplement.Implements
{
public class DisciplineStorage
{
}
}

View File

@ -0,0 +1,85 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.StorageContracts;
using UniversityContracts.ViewModels;
using UniversityDatabaseImplement.Models;
namespace UniversityDatabaseImplement.Implements
{
public class StatementStorage: IStatementStorage
{
public StatementViewModel? GetElement(StatementSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new UniversityDatabase();
return context.Statements.Include(x => x.Teacher).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public List<StatementViewModel> GetFilteredList(StatementSearchModel model)
{
if (!model.Id.HasValue && !model.Date.HasValue)
{
return new();
}
using var context = new UniversityDatabase();
return context.Statements
.Where(x => x.Id == model.Id || model.Date <= x.Date)
.Include(x => x.Teacher)
.Select(x => x.GetViewModel)
.ToList();
}
public List<StatementViewModel> GetFullList()
{
using var context = new UniversityDatabase();
return context.Statements.Include(x => x.Teacher).Select(x => x.GetViewModel).ToList();
}
public StatementViewModel? Insert(StatementBindingModel model)
{
var newStatement = Statement.Create(model);
if (newStatement == null)
{
return null;
}
using var context = new UniversityDatabase();
context.Statements.Add(newStatement);
context.SaveChanges();
return context.Statements.Include(x => x.Teacher).FirstOrDefault(x => x.Id == newStatement.Id)?.GetViewModel;
}
public StatementViewModel? Update(StatementBindingModel model)
{
using var context = new UniversityDatabase();
var order = context.Statements.FirstOrDefault(x => x.Id == model.Id);
if (order == null)
{
return null;
}
order.Update(model);
context.SaveChanges();
return context.Statements.Include(x => x.Teacher).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
}
public StatementViewModel? Delete(StatementBindingModel model)
{
using var context = new UniversityDatabase();
var element = context.Statements.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Statements.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UniversityDatabaseImplement.Implements
{
public class StorekeeperStorage
{
}
}

View File

@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.StorageContracts;
using UniversityContracts.ViewModels;
using UniversityDatabaseImplement.Models;
// TODO
namespace UniversityDatabaseImplement.Implements
{
public class TeacherStorage: ITeacherStorage
{
public List<TeacherViewModel> GetFullList()
{
using var context = new UniversityDatabase();
return context.Teachers
.Select(x => x.GetViewModel)
.ToList();
}
public List<TeacherViewModel> GetFilteredList(TeacherSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return new();
}
using var context = new UniversityDatabase();
return context.Teachers
.Where(x => x.Name.Contains(model.Name))
.Select(x => x.GetViewModel)
.ToList();
}
public TeacherViewModel? GetElement(TeacherSearchModel model)
{
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return null;
}
using var context = new UniversityDatabase();
return context.Teachers
.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public TeacherViewModel? Insert(TeacherBindingModel model)
{
var newTeacher = Teacher.Create(model);
if (newTeacher == null)
{
return null;
}
using var context = new UniversityDatabase();
context.Teachers.Add(newTeacher);
context.SaveChanges();
return newTeacher.GetViewModel;
}
public TeacherViewModel? Update(TeacherBindingModel model)
{
using var context = new UniversityDatabase();
var component = context.Teachers.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
public TeacherViewModel? Delete(TeacherBindingModel model)
{
using var context = new UniversityDatabase();
var element = context.Teachers.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Teachers.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,69 @@
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;
using UniversityContracts.BindingModels;
using UniversityContracts.ViewModels;
using UniversityDataModels.Models;
namespace UniversityDatabaseImplement.Models
{
public class Discipline : IDisciplineModel
{
public int Id { get; private set; }
[Required]
public int TeacherId { get; private set; }
[Required]
public string Name { get; private set; } = string.Empty;
[Required]
public string Description { get; private set; } = string.Empty;
public virtual Teacher Teacher { get; set; } = new();
[ForeignKey("DisciplineId")]
public virtual List<StudentDiscipline> StudentDiscipline { get; set; } = new();
public static Discipline? Create(DisciplineBindingModel model)
{
if (model == null)
{
return null;
}
return new Discipline()
{
Id = model.Id,
TeacherId = model.TeacherId,
Name = model.Name,
Description = model.Description,
};
}
public static Discipline Create(DisciplineViewModel model)
{
return new Discipline()
{
Id = model.Id,
TeacherId = model.TeacherId,
Name = model.Name,
Description = model.Description,
};
}
public void Update(DisciplineBindingModel model)
{
if (model == null)
{
return;
}
Id = model.Id;
TeacherId = model.TeacherId;
Name = model.Name;
Description = model.Description;
}
public DisciplineViewModel GetViewModel => new()
{
Id = Id,
TeacherId = TeacherId,
Name = Name,
Description = Description,
};
}
}

View File

@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.ViewModels;
using UniversityDataModels.Models;
namespace UniversityDatabaseImplement.Models
{
public class Statement : IStatementModel
{
public int Id { get; private set; }
[Required]
public int TeacherId { get; private set; }
[Required]
public string Name { get; private set; } = string.Empty;
[Required]
public DateTime Date { get; private set; }
public virtual Teacher Teacher { get; set; } = new ();
public static Statement? Create(StatementBindingModel model)
{
if (model == null)
{
return null;
}
return new Statement()
{
Id = model.Id,
TeacherId = model.TeacherId,
Name = model.Name,
Date = model.Date,
};
}
public static Statement Create(StatementViewModel model)
{
return new Statement()
{
Id = model.Id,
TeacherId = model.TeacherId,
Name = model.Name,
Date = model.Date,
};
}
public void Update(StatementBindingModel model)
{
if (model == null)
{
return;
}
Id = model.Id;
TeacherId = model.Id;
Name = model.Name;
Date = model.Date;
}
public StatementViewModel GetViewModel => new()
{
Id = Id,
TeacherId = TeacherId,
Name = Name,
Date = Date,
};
}
}

View File

@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.ViewModels;
using UniversityDataModels.Models;
namespace UniversityDatabaseImplement.Models
{
public class Storekeeper : IStorekeeperModel
{
public int Id { get; private set; }
[Required]
public string FirstName { get; private set; } = string.Empty;
[Required]
public string LastName { get; private set; } = string.Empty;
[Required]
public string MiddleName { get; private set; } = string.Empty;
[Required]
public string PhoneNumber { get; private set; } = string.Empty;
[Required]
public string Email { get; private set; } = string.Empty;
[ForeignKey("StorekeeperId")]
public virtual List<Teacher> Teachers { get; set; } = new();
public static Storekeeper? Create(StorekeeperBindingModel model)
{
if (model == null)
{
return null;
}
return new Storekeeper()
{
Id = model.Id,
FirstName = model.FirstName,
LastName = model.LastName,
MiddleName = model.MiddleName,
PhoneNumber = model.PhoneNumber,
Email = model.Email,
};
}
public static Storekeeper Create(StorekeeperViewModel model)
{
return new Storekeeper
{
Id = model.Id,
FirstName = model.FirstName,
LastName = model.LastName,
MiddleName = model.MiddleName,
PhoneNumber = model.PhoneNumber,
Email = model.Email,
};
}
public void Update(StorekeeperBindingModel model)
{
if (model == null)
{
return;
}
Id = model.Id;
FirstName = model.FirstName;
LastName = model.LastName;
MiddleName = model.MiddleName;
PhoneNumber = model.PhoneNumber;
Email = model.Email;
}
public StorekeeperViewModel GetViewModel => new()
{
Id = Id,
FirstName = FirstName,
LastName = LastName,
MiddleName = MiddleName,
PhoneNumber = PhoneNumber,
Email = Email,
};
}
}

View File

@ -2,10 +2,11 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModel;
using UniversityContracts.BindingModels;
using UniversityContracts.ViewModels;
using UniversityDataModels.Models;
@ -19,7 +20,8 @@ namespace UniversityDatabaseImplement.Models
public string Name { get; set; } = string.Empty;
[Required]
public string PhoneNumber { get; private set; } = string.Empty;
[ForeignKey("StudentId")]
public virtual List<StudentDiscipline> StudentDiscipline { get; set; } = new();
public static Student? Create(StudentBindingModel model)
{
if (model == null)

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UniversityDatabaseImplement.Models
{
public class StudentDiscipline
{
public int Id { get; set; }
[Required]
public int StudentId { get; set; }
[Required]
public int DisciplineId { get; set; }
public virtual Student Student { get; set; } = new ();
public virtual Discipline Discipline { get; set; } = new();
}
}

View File

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.ViewModels;
using UniversityDataModels.Models;
namespace UniversityDatabaseImplement.Models
{
public class Teacher : ITeacherModel
{
public int Id { get; private set; }
[Required]
public int StorekeeperId { get; private set; }
[Required]
public string Name { get; private set; } = string.Empty;
[Required]
public string AcademicDegree { get; private set; } = string.Empty;
[Required]
public string Position { get; private set; } = string.Empty;
public virtual Storekeeper Storekeeper { get; set; } = new ();
[ForeignKey("TeacherId")]
public virtual List<Statement> Statement { get; set; } = new();
[ForeignKey("TeacherId")]
public virtual List<Discipline> Discipline { get; set; } = new();
public static Teacher? Create(TeacherBindingModel model)
{
if (model == null)
{
return null;
}
return new Teacher()
{
Id = model.Id,
StorekeeperId = model.StorekeeperId,
Name = model.Name,
AcademicDegree = model.AcademicDegree,
Position = model.Position,
};
}
public static Teacher Create(TeacherViewModel model)
{
return new Teacher()
{
Id = model.Id,
StorekeeperId = model.StorekeeperId,
Name = model.Name,
AcademicDegree = model.AcademicDegree,
Position = model.Position,
};
}
public void Update(TeacherBindingModel model)
{
if (model == null)
{
return;
}
Id = model.Id;
StorekeeperId = model.StorekeeperId;
Name = model.Name;
AcademicDegree = model.AcademicDegree;
Position = model.Position;
}
public TeacherViewModel GetViewModel => new()
{
Id = Id,
StorekeeperId = StorekeeperId,
Name = Name,
AcademicDegree = AcademicDegree,
Position = Position,
};
}
}

View File

@ -11,7 +11,8 @@ namespace UniversityDatabaseImplement
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseNpgsql(@"Host=localhost;Port=5432;Database=PlumbingRepairDatabaseFull;Username=postgres;Password=postgres");
//Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR
optionsBuilder.UseSqlServer(@"Data Source=(localdb)\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
@ -19,6 +20,9 @@ namespace UniversityDatabaseImplement
public virtual DbSet<PlanOfStudy> PlansOfStudy { set; get; }
public virtual DbSet<Attestation> Attestations { set; get; }
// public virtual DbSet<Worker> Workers { set; get; }
// public virtual DbSet<Storekeeper> Storekeepers { set; get; }
public virtual DbSet<Storekeeper> Storekeepers { set; get; }
public virtual DbSet<Teacher> Teachers { set; get; }
public virtual DbSet<Discipline> Disciplines { set; get; }
public virtual DbSet<Statement> Statements { set; get; }
}
}