You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.4 KiB

10 years ago
  1. using System.ComponentModel.DataAnnotations;
  2. using System.ComponentModel.DataAnnotations.Schema;
  3. namespace Sevomin.Models
  4. {
  5. public class JobParameter
  6. {
  7. [Key]
  8. public long Id { get; set; }
  9. [Index("IX_JobParameterUniqueIndex", Order=1, IsUnique=true)]
  10. [Required]
  11. public long ParameterId { get; set; }
  12. [Index]
  13. [Index("IX_JobParameterUniqueIndex", Order=2, IsUnique=true)]
  14. [Required]
  15. public long JobId { get; set; }
  16. public string StringValue { get; private set; }
  17. public decimal? NumericValue { get; private set; }
  18. public byte Moscow { get; set; }
  19. public virtual Parameter Parameter { get; set; }
  20. public virtual Job Job { get; set; }
  21. public JobParameter()
  22. {}
  23. public JobParameter(Job job, Parameter parameter)
  24. {
  25. this.Job = job;
  26. this.Parameter = parameter;
  27. this.StringValue = "";
  28. this.NumericValue = null;
  29. this.Moscow = 0;
  30. }
  31. public void SetValue(string value)
  32. {
  33. decimal val;
  34. if (decimal.TryParse(value, out val))
  35. {
  36. NumericValue = val;
  37. StringValue = value;
  38. }
  39. else
  40. {
  41. NumericValue = null;
  42. StringValue = value;
  43. }
  44. }
  45. }
  46. }