public void InsertManagerCatalogProductLang(CatalogProductLangViewModel model) { var item = Mapper.Map <Catalog_Products_Lang>(model); m_ContentContext.Catalog_Products_Lang.Add(item); foreach (var langModel in model.Properties) { var lang = Mapper.Map <Catalog_Products_Properties_Lang>(langModel); m_ContentContext.Catalog_Products_Properties_Lang.Add(lang); } m_ContentContext.SaveChanges(); }
public void UpdateManagerCatalogProductLang(CatalogProductLangViewModel model) { var query = from p in m_ContentContext.Catalog_Products where p.Id == model.Id select p; var item = query.FirstOrDefault(); var langItem = item.Catalog_Products_Lang.FirstOrDefault(f => f.Id == model.Id); Mapper.Map(model, langItem); foreach (var langModel in model.Properties) { var litem = item.Catalog_Products_Properties.FirstOrDefault(f => f.Id == langModel.RefId).Catalog_Products_Properties_Lang.FirstOrDefault(f => f.Id == langModel.Id); Mapper.Map(langModel, litem); } m_ContentContext.SaveChanges(); }