58 lines
1.2 KiB
C#
58 lines
1.2 KiB
C#
|
using BulletinBoardContracts.BindingModels;
|
|||
|
using BulletinBoardContracts.ViewModels;
|
|||
|
using BulletinBoardDataModels.Models;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel.DataAnnotations;
|
|||
|
using System.ComponentModel.DataAnnotations.Schema;
|
|||
|
using System.Diagnostics;
|
|||
|
using System.Linq;
|
|||
|
using System.Numerics;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace BulletinBoardDatabase.Models
|
|||
|
{
|
|||
|
public class Region : IRegionModel
|
|||
|
{
|
|||
|
|
|||
|
[Required]
|
|||
|
public string RegionName { get; set; } = string.Empty;
|
|||
|
|
|||
|
public int? Id { get; private set; }
|
|||
|
|
|||
|
[ForeignKey("CityId")]
|
|||
|
public virtual List<City> Cities { get; set; } = new();
|
|||
|
|
|||
|
public static Region? Create(RegionBindingModel model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
return new Region()
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
RegionName = model.RegionName,
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public void Update(RegionBindingModel model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
RegionName = model.RegionName;
|
|||
|
}
|
|||
|
|
|||
|
public RegionViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
RegionName = RegionName,
|
|||
|
};
|
|||
|
|
|||
|
public string ObjectId => throw new NotImplementedException();
|
|||
|
}
|
|||
|
}
|