66 lines
1.3 KiB
C#
66 lines
1.3 KiB
C#
|
using Contracts.BindingModels;
|
|||
|
using Contracts.ViewModels;
|
|||
|
using DataModels.Models;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.ComponentModel.DataAnnotations;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace DatabaseImplement.Models
|
|||
|
{
|
|||
|
public class Book : IBook
|
|||
|
{
|
|||
|
[Required]
|
|||
|
public string Name { get; set; } = string.Empty;
|
|||
|
[Required]
|
|||
|
public string Readers { get; set; } = string.Empty;
|
|||
|
[Required]
|
|||
|
public string Shape { get; set; } = string.Empty;
|
|||
|
[Required]
|
|||
|
public string Annotation { get; set; } = string.Empty;
|
|||
|
|
|||
|
public int Id { get; set; }
|
|||
|
public static Book? Create(BookBindingModel model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
return new Book()
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
Annotation = model.Annotation,
|
|||
|
Name = model.Name,
|
|||
|
Readers = model.Readers,
|
|||
|
Shape = model.Shape
|
|||
|
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public void Update(BookBindingModel model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
Name = model.Name;
|
|||
|
Readers = model.Readers;
|
|||
|
Shape = model.Shape;
|
|||
|
Annotation = model.Annotation;
|
|||
|
|
|||
|
}
|
|||
|
public BookViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
Annotation = Annotation,
|
|||
|
Name = Name,
|
|||
|
Readers = Readers,
|
|||
|
Shape = Shape
|
|||
|
|
|||
|
};
|
|||
|
}
|
|||
|
}
|