public async Task ChangeByProp(ChangeByPropInput input) { switch (input.prop) { case "Name": await ProcessStringProp(input); break; default: break; } }
private async Task ProcessStringProp(ChangeByPropInput input) { var stringVal = ((string[])input.value)[0]; var todo = _todoManager.GetTodo(input.pk); if (todo == null) { return; } var oldValue = todo.TodoName; var property = todo.GetType().GetProperty(input.prop); if (property == null) { throw new UserFriendlyException("Property not found"); } property.SetValue(todo, stringVal); _todoManager.CreateEditTodo(todo); var todoListId = _todoManager.GetTodoListId(todo); var projectId = _toDoListManager.GetProjectIdFromList(todoListId); var project = _projectManager.GetProject(projectId); await _projectNotificationPublisherService.NameChanged(todo, oldValue, project); }
private async Task ProcessStringProp(ChangeByPropInput input) { var stringVal = ((string[])input.value)[0]; var todoList = _toDoListManager.GetList(input.pk); var oldValue = todoList.Name; if (todoList == null) { return; } var property = todoList.GetType().GetProperty(input.prop); if (property == null) { return; } property.SetValue(todoList, stringVal); _toDoListManager.CreateList(todoList); var projectId = _toDoListManager.GetProjectIdFromList(input.pk); var project = _projectManager.GetProject(projectId); //Notify about the list change await _projectNotificationPublisherService.NameChangedTodoList(todoList, oldValue, project); }