using BarContracts.BindingModels;
using BarContracts.ViewModels;
using BarDataModels.Models;

namespace BarListImplement.Models
{
	public class MessageInfo : IMessageInfoModel
	{
		public int Id { get; set; }

		public string MessageId { get; set; } = string.Empty;

		public int? ClientId { get; set; }

		public string SenderName { get; set; } = string.Empty;

		public DateTime DateDelivery { get; set; }

		public string Subject { get; set; } = string.Empty;

		public string Body { get; set; } = string.Empty;

		public static MessageInfo? Create(MessageInfoBindingModel? Model)
		{
			if (Model == null)
				return null;

			return new()
			{
				MessageId = Model.MessageId,
				ClientId = Model.ClientId,
				SenderName = Model.SenderName,
				DateDelivery = Model.DateDelivery,
				Subject = Model.Subject,
				Body = Model.Body
			};
		}

		public MessageInfoViewModel GetViewModel => new()
		{
			MessageId = MessageId,
			ClientId = ClientId,
			SenderName = SenderName,
			DateDelivery = DateDelivery,
			Subject = Subject,
			Body = Body
		};
	}
}
