public void Add(ModelDescriptionModel model) { var currentList = new List <ModelDescriptionModel>(); if (!string.IsNullOrEmpty(_vendorSetting.Value)) { currentList = _vendorSetting.Value.FromJson <List <ModelDescriptionModel> >(); } currentList.Add(model); _vendorSetting.Value = currentList.ToJson(); _unit.Save(); }
public ActionResult Create(ModelDescriptionModel model) { try { using (var unit = GetUnitOfWork()) { var repo = new ProductModelRepository(unit, _defaultVendorID); repo.Add(model); } return(Success("Successfully added type")); } catch (Exception e) { return(Failure("Something went wrong ", e)); } }
public void Update(string modelCode, string translation) { var currentList = new List <ModelDescriptionModel>(); if (!string.IsNullOrEmpty(_vendorSetting.Value)) { currentList = _vendorSetting.Value.FromJson <List <ModelDescriptionModel> >(); } var setting = currentList.FirstOrDefault(c => c.ModelCode == modelCode); if (setting == null) { setting = new ModelDescriptionModel(); currentList.Add(setting); setting.ModelCode = modelCode; } setting.Translation = translation; _vendorSetting.Value = currentList.ToJson(); _unit.Save(); }