Merge branch 'CourseWork' of http://student.git.athene.tech/AnnZhimol/CourseWork_Hotel into CourseWork
This commit is contained in:
commit
0b29e90218
@ -68,7 +68,7 @@ namespace HotelDataBaseImplement.Models
|
||||
var conferenceMembers = context.ConferenceMembers.Where(rec => rec.ConferenceId == model.Id).ToList();
|
||||
|
||||
if (conferenceMembers != null)
|
||||
{ // удалили те, которых нет в модели
|
||||
{
|
||||
context.ConferenceMembers.RemoveRange(conferenceMembers.Where(rec => !model.ConferenceMembers.ContainsKey(rec.MemberId)));
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ namespace HotelDataBaseImplement.Models
|
||||
var mealPlanMembers = context.MealPlanMembers.Where(rec => rec.MealPlanId == model.Id).ToList();
|
||||
|
||||
if (mealPlanMembers != null)
|
||||
{ // удалили те, которых нет в модели
|
||||
{
|
||||
context.MealPlanMembers.RemoveRange(mealPlanMembers.Where(rec => !model.MealPlanMembers.ContainsKey(rec.MemberId)));
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
using HotelDataModels.Models;
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.ViewModels;
|
||||
using HotelDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
@ -23,7 +25,43 @@ namespace HotelDataBaseImplement.Models
|
||||
|
||||
[ForeignKey("MemberId")]
|
||||
public virtual List<ConferenceMember> ConferenceMember { get; set; }
|
||||
public static Member? Create(MemberBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Member()
|
||||
{
|
||||
Id = model.Id,
|
||||
MemberFIO = model.MemberFIO,
|
||||
Citizenship = model.Citizenship
|
||||
};
|
||||
}
|
||||
public static Member Create(MemberViewModel model)
|
||||
{
|
||||
return new Member
|
||||
{
|
||||
Id = model.Id,
|
||||
MemberFIO = model.MemberFIO,
|
||||
Citizenship = model.Citizenship
|
||||
};
|
||||
}
|
||||
public void Update(MemberBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MemberFIO = model.MemberFIO;
|
||||
Citizenship = model.Citizenship;
|
||||
}
|
||||
public MemberViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
MemberFIO = MemberFIO,
|
||||
Citizenship = Citizenship
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user