using GreenTree.Strohrmann.ERP.Core.Domain.Rights;
using GreenTree.Strohrmann.ERP.Web.Models.Shared;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace GreenTree.Strohrmann.ERP.Web.Models.Business
{
public class CustomerModel : TrackingModel
{
#region Properties
///
/// Customer id
///
[Display(Name = "ID")]
public int Id { get; set; }
///
/// Customer title
///
[Display(Name = "Anrede")]
public TitleModel Title { get; set; }
///
/// Customer forename
///
[Display(Name = "Vorname")]
public string Firstname { get; set; }
///
/// Customer lastname
///
[Display(Name = "Nachname")]
public string Lastname { get; set; }
///
/// Customer full name
///
[Display(Name = "Voller Name")]
public string Fullname
{
get
{
return String.Format("{0} {1}", Firstname, Lastname);
}
}
///
/// Customer company name
///
[Display(Name = "Firmenname")]
public string CompanyName { get; set; }
///
/// Customer business state
///
[Display(Name = "Geschäftskunde")]
public bool IsBusiness { get; set; }
///
/// Customer address
///
[Display(Name = "Adresse")]
public string Address { get; set; }
///
/// Customer town
///
[Display(Name = "Stadt")]
public string Town { get; set; }
///
/// Customer zip code
///
[Display(Name = "Postleitzahl")]
public string ZipCode { get; set; }
///
/// Local full name
///
[Display(Name = "Lokale Adresse")]
public string LocalAddress
{
get
{
return String.Format("{0}, {1} {2}", Address, ZipCode, Town);
}
}
///
/// Customer country
///
[Display(Name = "Land")]
public string Country { get; set; }
///
/// Customer tax
///
[Display(Name = "Steuersatz")]
public TaxModel Tax { get; set; }
///
/// Customer crafts
///
[Display(Name = "Gewerke")]
public string[] Crafts { get; set; }
#endregion
#region Ctor
///
/// Initializes a new instance of the CustomerModel class
///
public CustomerModel() { }
///
/// Initializes a new instance of the CustomerModel class
///
/// Base customer entity.
public CustomerModel(Core.Domain.Business.Customer customer)
: base(customer)
{
if (customer == null) return;
Id = customer.Id;
Title = new TitleModel(customer.Title);
Firstname = customer.Firstname;
Lastname = customer.Lastname;
CompanyName = customer.CompanyName;
IsBusiness = customer.IsBusiness;
Address = customer.Address;
Town = customer.Town;
ZipCode = customer.ZipCode;
Country = customer.Country;
Tax = new TaxModel(customer.Tax);
Crafts = customer.Crafts
.Select(c => c.Name)
.ToArray();
}
#endregion
}
}