public virtual TaskAttributeModel PrepareTaskAttributeModel(TaskAttributeModel model, TaskAttribute taskAttribute, bool excludeProperties = false) { Action <TaskAttributeLocalizedModel, int> localizedModelConfiguration = null; if (taskAttribute != null) { //fill in model values from the entity model = model ?? taskAttribute.ToModel <TaskAttributeModel>(); //prepare nested search model PrepareTaskAttributeValueSearchModel(model.TaskAttributeValueSearchModel, taskAttribute); //define localized model configuration action localizedModelConfiguration = (locale, languageId) => { locale.Name = _localizationService.GetLocalized(taskAttribute, entity => entity.Name, languageId, false, false); }; } if (!excludeProperties) { model.Locales = _localizedModelFactory.PrepareLocalizedModels(localizedModelConfiguration); } return(model); }
protected virtual void UpdateAttributeLocales(TaskAttribute taskAttribute, TaskAttributeModel model) { foreach (var localized in model.Locales) { _localizedEntityService.SaveLocalizedValue(taskAttribute, x => x.Name, localized.Name, localized.LanguageId); } }
public virtual IActionResult Edit(TaskAttributeModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings)) { return(AccessDeniedView()); } var taskAttribute = _taskAttributeService.GetTaskAttributeById(model.Id); if (taskAttribute == null) { //no customer attribute found with the specified id return(RedirectToAction("List")); } if (!ModelState.IsValid) { //if we got this far, something failed, redisplay form return(View(model)); } taskAttribute = model.ToEntity(taskAttribute); _taskAttributeService.UpdateTaskAttribute(taskAttribute); //activity log _customerActivityService.InsertActivity("EditTaskAttribute", string.Format(_localizationService.GetResource("ActivityLog.EditTaskAttribute"), taskAttribute.Id), taskAttribute); //locales UpdateAttributeLocales(taskAttribute, model); SuccessNotification(_localizationService.GetResource("Admin.Task.TaskAttributes.Updated")); if (!continueEditing) { return(RedirectToAction("List")); } //selected tab SaveSelectedTabName(); return(RedirectToAction("Edit", new { id = taskAttribute.Id })); }
public virtual IActionResult Create(TaskAttributeModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var taskAttribute = model.ToEntity <TaskAttribute>(); _taskAttributeService.InsertTaskAttribute(taskAttribute); //activity log _customerActivityService.InsertActivity("AddNewTaskAttribute", string.Format(_localizationService.GetResource("ActivityLog.AddNewTaskAttribute"), taskAttribute.Id), taskAttribute); //locales UpdateAttributeLocales(taskAttribute, model); SuccessNotification(_localizationService.GetResource("Admin.Task.TaskAttributes.Added")); if (!continueEditing) { return(RedirectToAction("List")); } //selected tab SaveSelectedTabName(); return(RedirectToAction("Edit", new { id = taskAttribute.Id })); } //prepare model model = _taskAttributeModelFactory.PrepareTaskAttributeModel(model, null, true); //if we got this far, something failed, redisplay form return(View(model)); }