public async Task<LocalIssue> CreateOrUpdateIssueAsync(LocalIssue issue)
        {
            using (context = new SqliteContext(BaseConnstr))
            {
                var existed = context.Issue
                    .AsNoTracking()
                    .Include(i => i.Row)
                    .Include(i => i.Column)
                    .FirstOrDefault(iss => iss.Id == issue.Id);
                mapper.Map(issue, existed);

                if (existed == null)
                {
                    var newiss = mapper.Map<SqliteIssue>(issue);
                    context.Attach(newiss.Row);
                    context.Attach(newiss.Column);

                    await context.AddAsync(newiss);
                    await context.SaveChangesAsync();
                    context.Update(newiss.Column);
                    context.Update(newiss.Row);
                    await context.SaveChangesAsync();
                    return mapper.Map<LocalIssue>(newiss);
                }

                context.Update(existed);
                await context.SaveChangesAsync();
                return issue;
            }
        }
        public async Task<RowInfo> CreateOrUpdateRowAsync(RowInfo row)
        {
            using (context = new SqliteContext(BaseConnstr))
            {
                if (row.Id == 0 || context.Row.Find(row.Id) == null)
                    await context.AddAsync(row);

                else context.Update(row);
                await context.SaveChangesAsync();
                return row;
            }
        }
        public async Task<ColumnInfo> CreateOrUpdateColumnAsync(ColumnInfo column)
        {
            using (context = new SqliteContext(BaseConnstr))
            {
                if (column.Id == 0 || context.Column.AsNoTracking()
                        .FirstOrDefault(c => c.Id == column.Id) == null)
                    await context.AddAsync(column);


                else context.Update(column);
                await context.SaveChangesAsync();
                return column;
            }
        }
예제 #4
0
        public async Task <BoardInfo> CreateOrUpdateBoardInfoAsync(BoardInfo info)
        {
            using (context = new SqliteContext(BaseConnstr))
            {
                if (info.Id == 0 || context.Board.AsNoTracking()
                    .FirstOrDefault(c => c.Id == info.Id) == null)
                {
                    await context.AddAsync(info);
                }

                else
                {
                    context.Update(info);
                }
                await context.SaveChangesAsync();

                return(info);
            }
        }
예제 #5
0
        public async Task <RowInfo> CreateOrUpdateRowAsync(RowInfo row)
        {
            using (context = new SqliteContext(BaseConnstr))
            {
                if (row.Id == 0 || context.Row.AsNoTracking()
                    .FirstOrDefault(c => c.Id == row.Id) == null)
                {
                    context.Attach(row.Board);
                    await context.AddAsync(row);
                }

                else
                {
                    context.Update(row);
                }
                await context.SaveChangesAsync();

                return(row);
            }
        }