示例#1
0
 public void SaveAboutCompany(AboutCompany aboutCompany)
 {
     if (aboutCompany.AboutCompanyID == 0)
     {
         context.AboutCompanies.Add(aboutCompany);
     }
     else
     {
         context.Entry(aboutCompany).State = EntityState.Modified;
     }
     context.SaveChanges();
 }
示例#2
0
        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);
            }
        }
示例#3
0
        protected AboutCompany ToModel(AboutCompanyViewModel vm)
        {
            AboutCompany model = Mapper.Map <AboutCompany>(vm);

            return(model);
        }
示例#4
0
 public ActionResult EditAboutCompany(AboutCompany about)
 {
     _repository.SaveAboutCompany(about);
     return(View());
 }
示例#5
0
 public Task SetAboutCompanyAsync(string ticker, AboutCompany aboutCompany)
 {
     throw new NotImplementedException();
 }