Esempio n. 1
0
        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 }));
        }
Esempio n. 2
0
        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));
        }