CraftModel.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 employees
  34. /// </summary>
  35. [Display(Name = "Stunden")]
  36. public List<CraftEmployeeModel> CraftEmployees { get; set; }
  37. /// <summary>
  38. /// Craft materials
  39. /// </summary>
  40. [Display(Name = "Material")]
  41. public List<CraftMaterialModel> CraftMaterials { get; set; }
  42. #endregion
  43. #region Ctor
  44. /// <summary>
  45. /// Initializes a new instance of the CraftModel class
  46. /// </summary>
  47. public CraftModel() { }
  48. /// <summary>
  49. /// Initializes a new instance of the CraftModel class
  50. /// </summary>
  51. /// <param name="craft">The base craft.</param>
  52. public CraftModel(Craft craft)
  53. {
  54. if (craft == null) return;
  55. Id = craft.Id;
  56. Name = craft.Name;
  57. CreationDate = craft.CreationDate;
  58. Customer = new CustomerModel(craft.Customer);
  59. CraftEmployees = craft.CraftEmployees
  60. .Select(ce => new CraftEmployeeModel(ce))
  61. .ToList();
  62. CraftMaterials = craft.CraftMaterials
  63. .Select(cm => new CraftMaterialModel(cm))
  64. .ToList();
  65. }
  66. #endregion
  67. }
  68. }