public async Task DeleteColumnAsync(int?columnId) { using (context = new SqliteContext(BaseConnstr)) { if (context.Column.First().Id == columnId) { var bindedIssues = context.Issue .Where(iss => iss.ColumnId == columnId); var newxtCol = context.Column.Skip(1).First(); foreach (var issue in bindedIssues) { issue.ColumnId = newxtCol.Id; } context.UpdateRange(bindedIssues); await context.SaveChangesAsync(); context.Column.Remove(context.Column.Find(columnId)); await context.SaveChangesAsync(); var t = context.Issue.ToList(); } else { var bindedIssues = context.Issue .Where(iss => iss.ColumnId == columnId); var previousCol = context.Column.LastOrDefault(r => r.Id < columnId); foreach (var issue in bindedIssues) { issue.ColumnId = previousCol.Id; } context.UpdateRange(bindedIssues); context.Column.Remove(context.Column.Find(columnId)); await context.SaveChangesAsync(); var t = context.Issue.ToList(); } } }
public async Task DeleteRowAsync(int? rowId) { using (context = new SqliteContext(BaseConnstr)) { if (context.Row.First().Id == rowId) { var bindedIssues = context.Issue .Where(iss => iss.RowId == rowId); var newxtRow = context.Row.Skip(1).First(); foreach (var issue in bindedIssues) issue.RowId = newxtRow.Id; context.UpdateRange(bindedIssues); await context.SaveChangesAsync(); context.Row.Remove(context.Row.Find(rowId)); await context.SaveChangesAsync(); var t = context.Issue.ToList(); } else { var bindedIssues = context.Issue .Where(iss => iss.RowId == rowId); var previousRow = context.Row.LastOrDefault(r => r.Id < rowId); foreach (var issue in bindedIssues) issue.RowId = previousRow.Id; context.UpdateRange(bindedIssues); context.Row.Remove(context.Row.Find(rowId)); await context.SaveChangesAsync(); var t = context.Issue.ToList(); } } }