Еще чуть доделал
This commit is contained in:
parent
7e1670bf0c
commit
7a7a491b5a
@ -59,14 +59,14 @@ namespace SchoolDatabaseImplement.Implements
|
||||
public ClubViewModel? Insert(ClubBindingModel model)
|
||||
{
|
||||
using var context = new SchoolDatabase();
|
||||
var newComputer = Club.Create(context, model);
|
||||
if (newComputer == null)
|
||||
var newElement = Club.Create(context, model);
|
||||
if (newElement == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Clubs.Add(newComputer);
|
||||
context.Clubs.Add(newElement);
|
||||
context.SaveChanges();
|
||||
return newComputer.GetViewModel;
|
||||
return newElement.GetViewModel;
|
||||
}
|
||||
public ClubViewModel? Update(ClubBindingModel model)
|
||||
{
|
||||
@ -74,17 +74,17 @@ namespace SchoolDatabaseImplement.Implements
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var Computer = context.Clubs.FirstOrDefault(rec =>
|
||||
var Element = context.Clubs.FirstOrDefault(rec =>
|
||||
rec.Id == model.Id);
|
||||
if (Computer == null)
|
||||
if (Element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Computer.Update(model);
|
||||
Element.Update(model);
|
||||
context.SaveChanges();
|
||||
Computer.UpdateLessons(context, model);
|
||||
Element.UpdateLessons(context, model);
|
||||
transaction.Commit();
|
||||
return Computer.GetViewModel;
|
||||
return Element.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -65,14 +65,14 @@ namespace SchoolDatabaseImplement.Implements
|
||||
public InterestViewModel? Insert(InterestBindingModel model)
|
||||
{
|
||||
using var context = new SchoolDatabase();
|
||||
var newComputer = Interest.Create(context, model);
|
||||
if (newComputer == null)
|
||||
var newElement = Interest.Create(context, model);
|
||||
if (newElement == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Interests.Add(newComputer);
|
||||
context.Interests.Add(newElement);
|
||||
context.SaveChanges();
|
||||
return newComputer.GetViewModel;
|
||||
return newElement.GetViewModel;
|
||||
}
|
||||
public InterestViewModel? Update(InterestBindingModel model)
|
||||
{
|
||||
@ -80,18 +80,18 @@ namespace SchoolDatabaseImplement.Implements
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var Computer = context.Interests.FirstOrDefault(rec =>
|
||||
var Element = context.Interests.FirstOrDefault(rec =>
|
||||
rec.Id == model.Id);
|
||||
if (Computer == null)
|
||||
if (Element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Computer.Update(model);
|
||||
Element.Update(model);
|
||||
context.SaveChanges();
|
||||
Computer.UpdateLessons(context, model);
|
||||
Computer.UpdateMaterials(context, model);
|
||||
Element.UpdateLessons(context, model);
|
||||
Element.UpdateMaterials(context, model);
|
||||
transaction.Commit();
|
||||
return Computer.GetViewModel;
|
||||
return Element.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user