CraftModel.cs 2.3 KB

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