public async Task <IActionResult> Create(UserVoice userVoice) { if (string.IsNullOrWhiteSpace(userVoice.Content)) { _agileLabsDbContext.Add(userVoice); await _agileLabsDbContext.SaveChangesAsync(); return(RedirectToAction(nameof(Thanks))); } return(View()); }
public bool addEntity(Tenant newTenant) { if (_context.Tenants.Where(c => c.SubDomainName == newTenant.SubDomainName).Count() == 0) { _context.Add(newTenant); saveAll(); string connectionString = null; try { connectionString = onTenantEntry(newTenant); } catch (Exception ex) { connectionString = null; } try { if (connectionString != null) { var dbContextOptionsBuilder = new DbContextOptionsBuilder <TenantContext>(); dbContextOptionsBuilder.UseNpgsql(_configuration.GetConnectionString("DefaultConnectionString")); TenantContext tenantContext_temp = new TenantContext(dbContextOptionsBuilder.Options); Tenant recent_tenant = tenantContext_temp.Tenants.Last(); recent_tenant.ConnectionStringName = connectionString; tenantContext_temp.SaveChanges(); } } catch (Exception ex) { return(false); } return(true); } else { return(false); } }
public void Add(Portfolio portfolio) { _context.Add(portfolio); _context.SaveChanges(); }