using EInk.Dtos; namespace EInk.Dtos { public class ColourCastDto { public string id { get; set; } public string slidesNumber { get; set; } public string createTime { get; set; } public string topic { get; set; } public string pattern { get; set; } public string result { get; set; } public List values { get; set; } = new List(); public int alarmLocation { get; set; } public int threshold { get; set; } public void Valid() { if (String.IsNullOrEmpty(id) || String.IsNullOrEmpty(id.Trim())) { throw new Exception("Empty id"); } if (String.IsNullOrEmpty(slidesNumber) || String.IsNullOrEmpty(slidesNumber.Trim())) { throw new Exception("Empty slidesNumber"); } try { DateTime valid = Convert.ToDateTime(createTime); } catch { throw new Exception("Incorrect createTime"); } if (String.IsNullOrEmpty(topic) || String.IsNullOrEmpty(topic.Trim())) { throw new Exception("Empty topic"); } if (String.IsNullOrEmpty(pattern) || String.IsNullOrEmpty(pattern.Trim())) { throw new Exception("Empty pattern"); } if (String.IsNullOrEmpty(result) || (result != "NG" && result != "OK")) { throw new Exception("Incorrect result"); } try { int valid = Convert.ToInt32(alarmLocation); } catch { throw new Exception("Incorrect alarmLocation"); } try { int valid = Convert.ToInt32(threshold); } catch { throw new Exception("Incorrect threshold"); } } } }