public IActionResult UpdateLocalizationLabel(UpdateLocalizationLabelModel model) { if (ModelState.IsValid) { var labels = _localizedLabelService.Query(n => n.Where(f => f.ObjectColumnName == model.ObjectColumnName && f.ObjectId == model.ObjectId)); int i = 0; foreach (var item in model.Label) { var original = labels.Find(n => (int)n.LanguageId == model.LanguageId[i]); if (original != null) { if (item.IsEmpty()) { //delete _localizedLabelService.DeleteById(original.LocalizedLabelId); } else { //update _localizedLabelService.Update(n => n.Set(f => f.Label, item).Where(f => f.LocalizedLabelId == original.LocalizedLabelId)); } } else { //create //_localizedLabelService.Create(SolutionDefaults.DefaultSolutionId, item, labels.First().LabelTypeCode, model.ObjectColumnName, model.ObjectId, (LanguageEnum)Enum.ToObject(typeof(LanguageEnum), model.LanguageId[i])); } i++; } return(UpdateSuccess()); } return(UpdateFailure(GetModelErrors())); }
public IActionResult UpdateLocalizationLabel(Guid objectId, string columnName) { UpdateLocalizationLabelModel model = new UpdateLocalizationLabelModel { ObjectLabels = _localizedLabelService.Query(n => n.Where(f => f.ObjectColumnName == columnName && f.ObjectId == objectId)), Languages = _languageService.Query(n => n.Sort(s => s.SortAscending(f => f.Name))), ObjectColumnName = columnName, ObjectId = objectId }; return(View(model)); }