44 lines
1.0 KiB
C#
44 lines
1.0 KiB
C#
using HotelContracts.BindingModels;
|
|
using HotelContracts.ViewModels;
|
|
using HotelDataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HotelDatabaseImplement.Models
|
|
{
|
|
public class Post : IPostModel
|
|
{
|
|
[Required]
|
|
public string PostName { get; set; } = string.Empty;
|
|
|
|
public int Id { get; set; }
|
|
public static Post? Create(PostBindingModel model)
|
|
{
|
|
if (model == null) return null;
|
|
return new Post()
|
|
{
|
|
Id = model.Id,
|
|
PostName = model.PostName
|
|
};
|
|
}
|
|
|
|
public void Update(PostBindingModel model)
|
|
{
|
|
if (model == null) return;
|
|
Id = model.Id;
|
|
PostName = model.PostName;
|
|
}
|
|
|
|
public PostViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
PostName = PostName
|
|
};
|
|
}
|
|
}
|