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;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Save <see cref="OzonProductPriceHistory"/> data into DB
        /// </summary>
        /// <param name="productHistoryRecord"></param>
        /// <returns></returns>
        public async Task <int> SaveProductHistoryAsync(OzonProductPriceHistory productHistoryRecord)
        {
            if (productHistoryRecord == null)
            {
                logger.Debug($"{nameof(productHistoryRecord)} is null!");

                return(0);
            }

            using (var client = new SqliteContext(_connectionString))
            {
                if (productHistoryRecord.Id == 0)
                {
                    client.OzonProductPriceHistories.Add(productHistoryRecord);
                    await client.SaveChangesAsync();
                }
                else
                {
                    client.Update(productHistoryRecord);
                    await client.SaveChangesAsync();
                }

                return(productHistoryRecord.Id);
            }
        }
        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;
            }
        }
Beispiel #5
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);
            }
        }
Beispiel #6
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);
            }
        }
Beispiel #7
0
 public void Update(NavLink page)
 {
     _context.Update(page);
     _context.SaveChanges();
 }
Beispiel #8
0
 public void Update(RelatedPages page)
 {
     _context.Update(page);
     _context.SaveChanges();
 }