| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- using GreenTree.Strohrmann.ERP.Core.Domain.Business;
- using GreenTree.Strohrmann.ERP.Web.Extension;
- using GreenTree.Strohrmann.ERP.Web.Models.Search;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Mvc.ViewFeatures;
- 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 CraftModel : ICustomerSearchable
- {
- #region Properties
- /// <summary>
- /// Craft id
- /// </summary>
- [Display(Name = "ID")]
- public int Id { get; set; }
- /// <summary>
- /// Craft name
- /// </summary>
- [Display(Name = "Name")]
- public string Name { get; set; }
- /// <summary>
- /// Craft creation date
- /// </summary>
- [Display(Name = "Gestartet am")]
- [DisplayFormat(ApplyFormatInEditMode = false, DataFormatString = "{0:dd.MM.yyyy}")]
- public DateTime CreationDate { get; set; }
- /// <summary>
- /// Craft customer
- /// </summary>
- [Display(Name = "Kunde")]
- public CustomerModel Customer { get; set; }
- /// <summary>
- /// Craft customer id
- /// </summary>
- [Display(Name = "Kunde")]
- public int CustomerId { get; set; }
- /// <summary>
- /// Craft customer text
- /// </summary>
- [Display(Name = "Kundenname")]
- public string CustomerText { get; set; }
- /// <summary>
- /// Craft comment
- /// </summary>
- [Display(Name = "Kommentar")]
- public string Comment { get; set; }
- /// <summary>
- /// Craft employees
- /// </summary>
- [Display(Name = "Stunden")]
- public Dictionary<string, CraftEmployeeModel> CraftEmployees { get; set; }
- /// <summary>
- /// Craft employee value sum
- /// </summary>
- [Display(Name = "Wert (Stunden)")]
- [DisplayFormat(DataFormatString = "{0:c2}")]
- public float CraftEmployeeValue
- {
- get
- {
- return CraftEmployees.Sum(ce => ce.Value.Value);
- }
- }
- /// <summary>
- /// Craft materials
- /// </summary>
- [Display(Name = "Material")]
- public Dictionary<string, CraftMaterialModel> CraftMaterials { get; set; }
- /// <summary>
- /// Craft material value sum
- /// </summary>
- [Display(Name = "Wert (Material)")]
- [DisplayFormat(DataFormatString = "{0:c2}")]
- public float CraftMaterialValue
- {
- get
- {
- return CraftMaterials.Sum(ce => ce.Value.Value);
- }
- }
- #endregion
- #region Ctor
- /// <summary>
- /// Initializes a new instance of the CraftModel class
- /// </summary>
- public CraftModel() { }
- /// <summary>
- /// Initializes a new instance of the CraftModel class
- /// </summary>
- /// <param name="craft">The base craft.</param>
- public CraftModel(Craft craft)
- {
- if (craft == null) return;
- Id = craft.Id;
- Name = craft.Name;
- CreationDate = craft.CreationDate;
- Customer = new CustomerModel(craft.Customer);
- CustomerText = Customer.Fullname;
- CustomerId = craft.Customer.Id;
- Comment = craft.Comment;
- CraftEmployees = craft.CraftEmployees
- .Select(ce => new CraftEmployeeModel(ce))
- .ToDictionary(ce => HtmlContentExtension.RandomId(), ce => ce);
- CraftMaterials = craft.CraftMaterials
- .Select(cm => new CraftMaterialModel(cm))
- .ToDictionary(cm => HtmlContentExtension.RandomId(), cm => cm);
- }
- #endregion
- }
- }
|