public async Task Create(WebViewInsertViewModel viewModel) { try { if (!await IsInDb(viewModel)) { _webView.Add(_mappingEngine.Map <DomainClasses.Entities.WebView>(viewModel)); await _unitOfWork.SaveChangesAsync(); } else { var webView = await _webView.FirstAsync(a => a.Session == viewModel.Session); _mappingEngine.Map(viewModel, webView); await _unitOfWork.SaveChangesAsync(); } } catch (Exception e) { Console.Write(e); } }
public async Task <bool> IsInDb(WebViewInsertViewModel viewModel) { return(await _webView.AnyAsync(a => a.Session == viewModel.Session && a.Ip == viewModel.Ip)); }