CraftModel.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using GreenTree.Strohrmann.ERP.Core.Domain.Business;
  2. using GreenTree.Strohrmann.ERP.Web.Models.Search;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel.DataAnnotations;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. namespace GreenTree.Strohrmann.ERP.Web.Models.Business
  9. {
  10. public class CraftModel : ICustomerSearchable
  11. {
  12. #region Properties
  13. /// <summary>
  14. /// Craft id
  15. /// </summary>
  16. [Display(Name = "ID")]
  17. public int Id { get; set; }
  18. /// <summary>
  19. /// Craft name
  20. /// </summary>
  21. [Display(Name = "Name")]
  22. public string Name { get; set; }
  23. /// <summary>
  24. /// Craft creation date
  25. /// </summary>
  26. [Display(Name = "Gestartet am")]
  27. public DateTime CreationDate { get; set; }
  28. /// <summary>
  29. /// Craft customer
  30. /// </summary>
  31. [Display(Name = "Kunde")]
  32. public CustomerModel Customer { get; set; }
  33. /// <summary>
  34. /// Craft customer id
  35. /// </summary>
  36. public int CustomerId { get; set; }
  37. /// <summary>
  38. /// Craft employees
  39. /// </summary>
  40. [Display(Name = "Stunden")]
  41. public List<CraftEmployeeModel> CraftEmployees { get; set; }
  42. /// <summary>
  43. /// Craft materials
  44. /// </summary>
  45. [Display(Name = "Material")]
  46. public List<CraftMaterialModel> CraftMaterials { get; set; }
  47. #endregion
  48. #region Ctor
  49. /// <summary>
  50. /// Initializes a new instance of the CraftModel class
  51. /// </summary>
  52. public CraftModel() { }
  53. /// <summary>
  54. /// Initializes a new instance of the CraftModel class
  55. /// </summary>
  56. /// <param name="craft">The base craft.</param>
  57. public CraftModel(Craft craft)
  58. {
  59. if (craft == null) return;
  60. Id = craft.Id;
  61. Name = craft.Name;
  62. CreationDate = craft.CreationDate;
  63. Customer = new CustomerModel(craft.Customer);
  64. CustomerId = craft.Customer.Id;
  65. CraftEmployees = craft.CraftEmployees
  66. .Select(ce => new CraftEmployeeModel(ce))
  67. .ToList();
  68. CraftMaterials = craft.CraftMaterials
  69. .Select(cm => new CraftMaterialModel(cm))
  70. .ToList();
  71. }
  72. #endregion
  73. }
  74. }