/// <summary>
        /// Returns View to add form of corresponding type
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public ActionResult AddUserInput(UserInputType type)
        {
            UserInputModel model = new UserInputModel();
            IUserInput     input;

            switch (type)
            {
            case UserInputType.Text:
                input = new TextInputDto();
                break;

            case UserInputType.ScriptedSelection:
                input = new ScriptedSelectionInputDto();
                break;

            case UserInputType.Selection:
                input = new SelectionInputDto {
                    Delimiter = ","
                };                                                                         //set the default to comma
                break;

            default:                     //need a default
                input = null;            //null is ok, razor will handle
                break;
            }

            model.InputType = type;
            model.UserInput = input;
            model.Action    = "Add";

            return(View("EditUserInput", model));
        }
        public ActionResult SaveScriptedSelectionInput(ScriptedSelectionInputDto input)
        {
            if (!ModelState.IsValid)             //server side validation
            {
                TempData["MessageType"] = WebMessageType.Failure;
                TempData["Message"]     = "Failed to save new User Input due to invalid data";
                if (input.Id == 0)                 //depending on user action at the time
                {
                    return(RedirectToAction("AddUserInput", new { type = UserInputType.ScriptedSelection }));
                }
                return(RedirectToAction("UpdateUserInput", new { type = UserInputType.ScriptedSelection, id = input.Id }));
            }


            int entityId;             //get returning id

            try
            {
                entityId =
                    _portfolioService.ModifyScriptedSelectionInput(UserId, input, input.Id > 0 ? EntityModification.Update : EntityModification.Create)
                    .Id;
            }
            catch (Exception exception)
            {
                TempData["MessageType"] = WebMessageType.Failure;
                TempData["Message"]     = $"Failed to save new User Input, error: {exception.Message}";
                if (input.Id == 0)                 //depending on user action at the time
                {
                    return(RedirectToAction("AddUserInput", new { type = UserInputType.ScriptedSelection }));
                }
                return(RedirectToAction("UpdateUserInput", new { type = UserInputType.ScriptedSelection, id = input.Id }));
            }
            TempData["MessageType"] = WebMessageType.Success;
            TempData["Message"]     = "Successfully saved new User Input";

            return(RedirectToAction("ShowUserInput", new { id = entityId, type = UserInputType.ScriptedSelection }));
        }