public void PostSeo(SeoAddModel model) { var product = Db.Product.Include(c => c.Seo).FirstOrDefault(c => c.ProductId == model.AssignTableId); if (product == null) { return; } if (product.Seo == null) { var seo = _mapper.Map <Seo>(model); product.Seo = seo; } else { product.Seo.MetaTitle = model.MetaTitle; product.Seo.MetaDescription = model.MetaDescription; product.Seo.MetaKeywords = model.MetaKeywords; } Db.Product.Update(product); }
public void PostSeo(SeoAddModel model) { var catalog = Db.Catalog.Include(c => c.Seo).FirstOrDefault(c => c.CatalogId == model.AssignTableId); if (catalog == null) { return; } if (catalog.Seo == null) { var seo = _mapper.Map <Seo>(model); catalog.Seo = seo; } else { catalog.Seo.MetaTitle = model.MetaTitle; catalog.Seo.MetaDescription = model.MetaDescription; catalog.Seo.MetaKeywords = model.MetaKeywords; } Db.Catalog.Update(catalog); }