CraftEmployeeModel.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using GreenTree.Strohrmann.ERP.Core.Domain.Business;
  2. using GreenTree.Strohrmann.ERP.Web.Models.Shared;
  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 CraftEmployeeModel
  11. {
  12. #region Properties
  13. /// <summary>
  14. /// Craft employee model index
  15. /// </summary>
  16. public int? Index { get; set; }
  17. /// <summary>
  18. /// Craft employee Dictionary identifier
  19. /// </summary>
  20. public string DictIdentifier { get; set; }
  21. /// <summary>
  22. /// Craft employee id
  23. /// </summary>
  24. public int Id { get; set; }
  25. /// <summary>
  26. /// Craft id
  27. /// </summary>
  28. [Display(Name = "ID")]
  29. public int CraftId { get; set; }
  30. /// <summary>
  31. /// Craft
  32. /// </summary>
  33. [Display(Name = "Gewerk")]
  34. public virtual CraftModel Craft { get; set; }
  35. /// <summary>
  36. /// Employee id
  37. /// </summary>
  38. [Display(Name = "Mitarbeiter")]
  39. public int EmployeeId { get; set; }
  40. /// <summary>
  41. /// Employee
  42. /// </summary>
  43. [Display(Name = "Mitarbeiter")]
  44. public virtual EmployeeModel Employee { get; set; }
  45. /// <summary>
  46. /// The amount of employee working hours
  47. /// </summary>
  48. [Display(Name = "Menge / Dauer")]
  49. public float Amount
  50. {
  51. get
  52. {
  53. return String.IsNullOrEmpty(AmountText)
  54. ? 0
  55. : Convert.ToSingle(AmountText.Replace('.',','));
  56. }
  57. set
  58. {
  59. AmountText = value.ToString();
  60. }
  61. }
  62. /// <summary>
  63. /// The amount of employee working hours as text
  64. /// </summary>
  65. [Display(Name = "Menge / Dauer")]
  66. public string AmountText { get; set; }
  67. /// <summary>
  68. /// The value of the employee working hours
  69. /// </summary>
  70. [Display(Name = "Wert")]
  71. [DisplayFormat(ApplyFormatInEditMode = false, DataFormatString = "{0:C}")]
  72. public float Value { get; set; }
  73. /// <summary>
  74. /// Craft employee comment
  75. /// </summary>
  76. [Display(Name = "Kommentar")]
  77. public string Comment { get; set; }
  78. #endregion
  79. #region Ctor
  80. /// <summary>
  81. /// Initializes a new instance of the CraftEmployeeModel class
  82. /// </summary>
  83. public CraftEmployeeModel() { }
  84. /// <summary>
  85. /// Initializes a new instance of the CraftEmployeeModel class
  86. /// </summary>
  87. /// <param name="craftEmployee">The base craft employee.</param>
  88. public CraftEmployeeModel(CraftEmployee craftEmployee)
  89. {
  90. if (craftEmployee == null) return;
  91. Id = craftEmployee.Id;
  92. CraftId = craftEmployee.CraftId;
  93. EmployeeId = craftEmployee.EmployeeId;
  94. Employee = new EmployeeModel(craftEmployee.Employee);
  95. Amount = craftEmployee.Amount;
  96. Value = craftEmployee.Value;
  97. Comment = craftEmployee.Comment;
  98. }
  99. #endregion
  100. }
  101. }