// returns true if month already exists private bool DoesMonthExistForUser(List <Month_Year> MonthsForUser, Month_Year NewMonth) { if (MonthsForUser.Any(M => M.Month == NewMonth.Month && M.Year == NewMonth.Year && M.UserId == NewMonth.UserId)) { return(true); } return(false); }
// adds new month and returns false if month already exists public bool AddMonth(Month_Year NewMonth) { using (ContextDBDataContext context = new ContextDBDataContext(_connectionString)) { if (DoesMonthExistForUser(context.Month_Years.Where(M => M.UserId == NewMonth.UserId).ToList(), NewMonth)) { return(true); } context.Month_Years.InsertOnSubmit(NewMonth); context.SubmitChanges(); return(false); } }
partial void DeleteMonth_Year(Month_Year instance);
partial void UpdateMonth_Year(Month_Year instance);
partial void InsertMonth_Year(Month_Year instance);
private void detach_Month_Years(Month_Year entity) { this.SendPropertyChanging(); entity.User = null; }
private void attach_Month_Years(Month_Year entity) { this.SendPropertyChanging(); entity.User = this; }