public RecordMailMonthly Prev_RecordMailMonthly(RecordMailMonthly m) { var list = GetRecordMailMonthlies(); if (m == null) { return(list.LastOrDefault()); } int index = list.IndexOf(list.SingleOrDefault(p => p.Id == m.Id)) - 1; if (index > -1) { return(list[index]); } return(null); }
public void AddRecordMailMonthly_Validating(RecordMailMonthly o) { if (o is null) { throw new ValidatingException("Item invalid!"); } if (o.RecordMails?.Any() != true) { throw new ValidatingException("Record mails have no items to record"); } var r = GetRecordMailMonthly(o.Monthly); if (r != null) { throw new ValidatingException("Can not save in duplicated month!"); } using (var con = Connection) { var col = con.GetCollection <RecordMailMonthly>(typeof(RecordMailMonthly).Name); col.Insert(o); } }