public ActionResult Create(ActionType actionType, int jobId)
        {
            ICreateViewModel viewModel = null;

            switch (actionType)
            {
            case ActionType.EmailActionConfiguration:

                viewModel = new CreateEmailActionViewModel
                {
                    ActionType          = actionType,
                    ActionConfiguration = new EmailActionConfiguration
                    {
                        JobConfigurationId = jobId
                    }
                };
                break;

            case ActionType.HipchatActionConfiguration:
                viewModel = new CreateHipChatActionViewModel
                {
                    ActionType          = actionType,
                    ActionConfiguration = new HipchatActionConfiguration()
                    {
                        JobConfigurationId = jobId
                    }
                };
                break;

            default:
                throw new NotSupportedException();
            }
            return(View(viewModel));
        }
        public async Task <ActionResult> Edit(int?id, ActionType actionType)
        {
            ICreateViewModel viewModel = null;

            if (id.HasValue)
            {
                var action = await Database.ActionConfigurations.SingleOrDefaultAsync(j => j.Id == id.Value);

                if (action == null)
                {
                    return(HttpNotFound());
                }
                else
                {
                    switch (actionType)
                    {
                    case ActionType.EmailActionConfiguration:
                        viewModel = new CreateEmailActionViewModel
                        {
                            ActionType          = actionType,
                            ActionConfiguration = (EmailActionConfiguration)action
                        };
                        break;

                    case ActionType.HipchatActionConfiguration:
                        viewModel = new Models.ViewModels.ActionConfiguration.CreateHipChatActionViewModel()
                        {
                            ActionType          = actionType,
                            ActionConfiguration = (HipchatActionConfiguration)action
                        };
                        break;
                    }

                    return(View(viewModel));
                }
            }
            else
            {
                return(RedirectToAction("Create", new { actionType = actionType }));
            }
        }