Skip to content

Commit

Permalink
added a dataset service
Browse files Browse the repository at this point in the history
  • Loading branch information
Nityan Khanna committed May 7, 2018
1 parent e5cf2aa commit 3b6044f
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 0 deletions.
46 changes: 46 additions & 0 deletions OpenIZAdmin.Services/Dataset/DatasetService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2016-2018 Mohawk College of Applied Arts and Technology
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You may
* obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*
* User: khannan
* Date: 2018-5-7
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenIZ.Core.Model.Entities;

namespace OpenIZAdmin.Services.Dataset
{
/// <summary>
/// Class DatasetService.
/// </summary>
/// <seealso cref="OpenIZAdmin.Services.Dataset.IDatasetService" />
public class DatasetService : IDatasetService
{
/// <summary>
/// Converts an entity or derived entity to a dataset instance.
/// </summary>
/// <typeparam name="T">The type of instance to convert to a dataset.</typeparam>
/// <param name="instance">The instance.</param>
/// <returns>Returns the dataset.</returns>
/// <exception cref="NotImplementedException"></exception>
public DataInstallAction ConvertToDataset<T>(T instance) where T : Entity
{
throw new NotImplementedException();
}
}
}
41 changes: 41 additions & 0 deletions OpenIZAdmin.Services/Dataset/IDatasetService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2016-2018 Mohawk College of Applied Arts and Technology
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You may
* obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*
* User: khannan
* Date: 2018-5-7
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenIZ.Core.Model.Entities;

namespace OpenIZAdmin.Services.Dataset
{
/// <summary>
/// Represents a dataset service.
/// </summary>
public interface IDatasetService
{
/// <summary>
/// Converts an entity or derived entity to a dataset instance.
/// </summary>
/// <typeparam name="T">The type of instance to convert to a dataset.</typeparam>
/// <param name="instance">The instance.</param>
/// <returns>Returns the dataset.</returns>
DataInstallAction ConvertToDataset<T>(T instance) where T : Entity;
}
}
2 changes: 2 additions & 0 deletions OpenIZAdmin.Services/OpenIZAdmin.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@
<Compile Include="Dataset\DataInstallAction.cs" />
<Compile Include="Dataset\DataObsolete.cs" />
<Compile Include="Dataset\DatasetInstall.cs" />
<Compile Include="Dataset\DatasetService.cs" />
<Compile Include="Dataset\DataUpdate.cs" />
<Compile Include="Dataset\IDatasetService.cs" />
<Compile Include="Entities\EntityService.cs" />
<Compile Include="Core\ImsiServiceBase.cs" />
<Compile Include="Core\AmiServiceBase.cs" />
Expand Down
21 changes: 21 additions & 0 deletions OpenIZAdmin/Controllers/MaterialController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,27 @@ public ActionResult Delete(Guid id)
return RedirectToAction("Index");
}

/// <summary>
/// Downloads as dataset.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>Returns the material as a dataset instance.</returns>
[HttpGet]
public ActionResult DownloadAsDataset(Guid id)
{
try
{

}
catch (Exception e)
{
this.TempData["error"] = Locale.UnexpectedErrorMessage;
Trace.TraceError($"Unable to download material: {e}");
}

return RedirectToAction("ViewMaterial", "Material", id);
}

/// <summary>
/// Edit for material.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions OpenIZAdmin/Dependency/DependencyConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
using OpenIZAdmin.DAL.Manuals;
using OpenIZAdmin.Services.Applets;
using OpenIZAdmin.Services.Auditing;
using OpenIZAdmin.Services.Dataset;
using OpenIZAdmin.Services.Entities;
using OpenIZAdmin.Services.Entities.ManufacturedMaterials;
using OpenIZAdmin.Services.Entities.Materials;
Expand Down Expand Up @@ -142,6 +143,9 @@ public void Register(ContainerBuilder builder)
// register entity relationship services
builder.RegisterType<EntityRelationshipService>().As<IEntityRelationshipService>().InstancePerLifetimeScope();

// register dataset services
builder.RegisterType<DatasetService>().As<IDatasetService>().InstancePerLifetimeScope();

// register server information services
builder.RegisterType<AmiServerInformationService>().As<IAmiServerInformationService>().InstancePerLifetimeScope();
builder.RegisterType<ImsiServerInformationService>().As<IImsiServerInformationService>().InstancePerLifetimeScope();
Expand Down

0 comments on commit 3b6044f

Please sign in to comment.