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.

55 lines
1.4 KiB

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