public ActionResult AddVersion([DataSourceRequest] DataSourceRequest request,
                                       [Bind(Prefix = "models")] IEnumerable <AssetVersionModel> versions, int fileType, int meterGroup, int versionGroup)
        {
            var versionFactory = new VersionFactory(Session[Constants.Security.ConnectionStringSessionVariableName].ToString());


            // Get new version
            var newVersion = versions.FirstOrDefault(m => m.Id == 0);

            if (newVersion != null)
            {
                // Does this version already exist?
                if (versionFactory.VersionExists(newVersion.Name, fileType, meterGroup, versionGroup))
                {
                    // Return an error to caller.
                    ModelState.AddModelError("Version", "This version already exists.");
                }
                else
                {
                    // Save new version.
                    versionFactory.AddVersion(newVersion.Name, fileType, meterGroup, versionGroup);
                }
            }

            if (ModelState.IsValid)
            {
                var versionList = versionFactory.GetVersionSetModel(fileType, meterGroup, versionGroup);

                var result = new DataSourceResult
                {
                    Data  = versionList.Versions,
                    Total = versionList.Versions.Count
                };

                // Return new list.
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            // Return the error
            return(Json(ModelState.ToDataSourceResult(), JsonRequestBehavior.AllowGet));
        }