<commit_before>﻿using IronBank.ServicesModel;
using IronBank.ViewModels;
using System;
using System.Linq;
using System.Web.Mvc;

namespace IronBank.Controllers
{
    [Authorize]
    public class ServicesController : IronController
    {
        private readonly ServiceManager payableServicesManager;

        public ServicesController() 
        {
            payableServicesManager =
                new ServiceManager(db)
                    .SetContextUser(Authentication.CurrentUser);
        }

        public ActionResult Index()
        {
            return View(payableServicesManager.GetConfiguredServices());
        }

        [HttpGet]
        public ActionResult Configure()
        {
            return View(new ServiceConfiguration() { AvailableServices = payableServicesManager.GetAvailableServices() });
        }

        [HttpPost]
        public ActionResult Configure(ServiceConfiguration model)
        {
            try 
            {
                return View("Index", payableServicesManager.GetConfiguredServices());
            } 
            catch (InvalidOperationException error) 
            {
                ModelState.AddModelError("Configuration", error.Message);
                model.AvailableServices = db.AvailableServices.ToList();
                return View(model);
            }
        }
    }
}<commit_msg>Fixed Null Reference After Create. By redirecting to Action.<commit_after>﻿using IronBank.ServicesModel;
using IronBank.ViewModels;
using System;
using System.Linq;
using System.Web.Mvc;

namespace IronBank.Controllers
{
    [Authorize]
    public class ServicesController : IronController
    {
        private readonly ServiceManager payableServicesManager;

        public ServicesController() 
        {
            payableServicesManager =
                new ServiceManager(db)
                    .SetContextUser(Authentication.CurrentUser);
        }

        public ActionResult Index()
        {
            return View(payableServicesManager.GetConfiguredServices());
        }

        [HttpGet]
        public ActionResult Configure()
        {
            return View(new ServiceConfiguration() { AvailableServices = payableServicesManager.GetAvailableServices() });
        }

        [HttpPost]
        public ActionResult Configure(ServiceConfiguration model)
        {
            try 
            {
                payableServicesManager.Configure(model.ServiceId, model.ContractReference);
                return RedirectToAction("Index");
            } 
            catch (InvalidOperationException error) 
            {
                ModelState.AddModelError("Configuration", error.Message);
                model.AvailableServices = db.AvailableServices.ToList();
                return View(model);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.07369170523317907, 'fraction_numerical': 0.0, 'mean_word_length': 2.0280172413793105, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4497889', 'n_tokens_mistral': 649, 'n_tokens_neox': 619, 'n_words': 127}