using LiteCharms.Features.MidrandBooks.AuthorBooks.Models; using LiteCharms.Features.MidrandBooks.Authors.Models; using LiteCharms.Features.MidrandBooks.Categories.Models; using LiteCharms.Features.MidrandBooks.Customers.Models; using LiteCharms.Features.MidrandBooks.Orders.Models; using LiteCharms.Features.MidrandBooks.Pages.Models; using LiteCharms.Features.MidrandBooks.Products.Models; namespace LiteCharms.Features.MidrandBooks.Extensions; public static class Mappers { public static Category ToModel(this Categories.Entities.Category entity) => new() { Id = entity.Id, Name = entity.Name, IsMain = entity.IsMain, Enabled = entity.Enabled, }; public static ShippingProvider ToModel(this Orders.Entities.ShippingProvider entity) => new() { Id = entity.Id, CreatedAt = entity.CreatedAt, UpdatedAt = entity.UpdatedAt, Name = entity.Name, Type = entity.Type, Price = entity.Price, Enabled = entity.Enabled, TrackingUrl = entity.TrackingUrl, }; public static Shipping ToModel(this Orders.Entities.Shipping entity) => new() { Id = entity.Id, CreatedAt = entity.CreatedAt, UpdatedAt = entity.UpdatedAt, OrderId = entity.OrderId, AddressId = entity.AddressId, Status = entity.Status, TrackingNumber = entity.TrackingNumber }; public static OrderItem ToModel(this Orders.Entities.OrderItem entity) => new() { Id = entity.Id, CreatedAt = entity.CreatedAt, OrderId = entity.OrderId, Quantity = entity.Quantity, AuthorBookId = entity.AuthorBookId, ProductPriceId = entity.ProductPriceId }; public static Order ToModel(this Orders.Entities.Order entity) => new() { Id = entity.Id, CustomerId = entity.CustomerId, CreatedAt = entity.CreatedAt, UpdatedAt = entity.UpdatedAt, Status = entity.Status, Total = entity.Total, InvoiceUrl = entity.InvoiceUrl, Notes = entity.Notes }; public static Customer ToModel(this Customers.Entities.Customer entiry) => new() { Id = entiry.Id, Company = entiry.Company, CreatedAt = entiry.CreatedAt, Email = entiry.Email, Enabled = entiry.Enabled, Phone = entiry.Phone, SocialMedia = entiry.SocialMedia, UpdatedAt = entiry.UpdatedAt, VatNumber = entiry.VatNumber, Website = entiry.Website }; public static Address ToModel(this Customers.Entities.Address entity) => new() { Id = entity.Id, BuildingType = entity.BuildingType, CreatedAt = entity.CreatedAt, CustomerId = entity.CustomerId, Enabled = entity.Enabled, IsPrimary = entity.IsPrimary, Name = entity.Name, PostalCode = entity.PostalCode, Type = entity.Type, UpdatedAt = entity.UpdatedAt, Street = entity.Street, City = entity.City, State = entity.State, Country = entity.Country }; public static Contact ToModel(this Customers.Entities.Contact entity) => new() { Id = entity.Id, Type = entity.Type, CreatedAt = entity.CreatedAt, UpdatedAt = entity.UpdatedAt, CustomerId = entity.CustomerId, Email = entity.Email, Enabled = entity.Enabled, LastName = entity.LastName, Name = entity.Name, Phone = entity.Phone }; public static BookPage ToModel(this Pages.Entities.BookPage entity) => new() { Id = entity.Id, CreatedAt = entity.CreatedAt, UpdatedAt = entity.UpdatedAt, AuthorBookId = entity.AuthorBookId, Content = entity.Content, ContentType = entity.ContentType, Number = entity.Number, Enabled = entity.Enabled, Notes = entity.Notes, References = entity.References, Type = entity.Type }; public static AuthorBook ToModel(this AuthorBooks.Entities.AuthorBook entity) => new() { Id = entity.Id, ProductId = entity.ProductId, CreatedAt = entity.CreatedAt, AuthorId = entity.AuthorId, Ranking = entity.Ranking, Rating = entity.Rating, Enabled = entity.Enabled, Product = entity.Product?.ToModel(), }; public static ProductPrice ToModel(this Products.Entities.ProductPrice entity) => new() { Id = entity.Id, CreatedAt = entity.CreatedAt, UpdatedAt = entity.UpdatedAt, ProductId = entity.ProductId, Amount = entity.Amount, Discount = entity.Discount, Enabled = entity.Enabled }; public static Product ToModel(this Products.Entities.Product entity) => new Product { Id = entity.Id, CreatedAt = entity.CreatedAt, UpdatedAt = entity.UpdatedAt, Name = entity.Name, Summary = entity.Summary, Description = entity.Description, Type = entity.Type, ImageUrl = entity.ImageUrl, ThumbnailUrls = entity.ThumbnailUrls, Metadata = entity.Metadata, Enabled = entity.Enabled, Price = entity.Prices?.FirstOrDefault(p => p.Enabled)?.ToModel() ?? null, }; public static Author ToModel(this Authors.Entities.Author entity) => new() { Id = entity.Id, CreatedAt = entity.CreatedAt, UpdatedAt = entity.UpdatedAt, Name = entity.Name, LastName = entity.LastName, Biography = entity.Biography, Email = entity.Email, Website = entity.Website, ImageUrl = entity.ImageUrl, ThumbnailImageUrl = entity.ThumbnailImageUrl, SocialMedia = entity.SocialMedia, Enabled = entity.Enabled, Company = entity.Company, PublisherType = entity.PublisherType, VatNumber = entity.VatNumber }; }