public void SaveAboutCompany(AboutCompany aboutCompany) { if (aboutCompany.AboutCompanyID == 0) { context.AboutCompanies.Add(aboutCompany); } else { context.Entry(aboutCompany).State = EntityState.Modified; } context.SaveChanges(); }
public async Task SetAboutCompanyAsync(string ticker, AboutCompany aboutCompany) { using (var connection = new NpgsqlConnection(dbConnection)) { var query = "UPDATE companies SET name = @name, industry = @industry, logo = @logo, date_added = now() WHERE ticker = @ticker;" + "INSERT INTO companies(name, ticker, industry, logo, date_added)" + "SELECT @name, @ticker, @industry, @logo, now()" + "WHERE NOT EXISTS(SELECT 1 FROM companies WHERE ticker = @ticker); "; var param = new { ticker = ticker, name = aboutCompany.Name, industry = aboutCompany.Industry, logo = aboutCompany.Logo, }; await connection.ExecuteAsync(query, param); } }
protected AboutCompany ToModel(AboutCompanyViewModel vm) { AboutCompany model = Mapper.Map <AboutCompany>(vm); return(model); }
public ActionResult EditAboutCompany(AboutCompany about) { _repository.SaveAboutCompany(about); return(View()); }
public Task SetAboutCompanyAsync(string ticker, AboutCompany aboutCompany) { throw new NotImplementedException(); }