Skip to content

Commit

Permalink
Added public api
Browse files Browse the repository at this point in the history
  • Loading branch information
zmn committed Apr 9, 2017
1 parent b7d4369 commit 31b28ce
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Wlog.Library/BLL/Reporitories/DBKeyPairRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public string GetByKey(Guid dictionaryId, string key)
{
using (var op = this.BeginUnitOfWork())
{
var item = op.Query<KeyPairEntity>().Where(x => x.DictionaryId.CompareTo(dictionaryId) == 0 && x.ItemKey.Equals(key)).FirstOrDefault();
var item = op.Query<KeyPairEntity>().Where(x => x.DictionaryId.Equals(dictionaryId) && x.ItemKey.Equals(key)).FirstOrDefault();
if (item == null) return null;
return item.ItemValue;
}
Expand Down
43 changes: 43 additions & 0 deletions Wlog.Web/Code/API/DictionaryController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using NLog;
using Wlog.BLL.Entities;
using Wlog.Library.BLL.Reporitories;

namespace Wlog.Web.Code.API
{
[AllowAnonymous]
public class DictionaryController : ApiController
{
private readonly Logger _logger = LogManager.GetCurrentClassLogger();



public KeyPairEntity Get(Guid publicKey, string dictionaryName, string key)
{
try
{
var application = RepositoryContext.Current.Applications.GetByApplicationKey(publicKey.ToString());
if (application == null) throw new Exception("Unable to find appliction");
var dictionary = RepositoryContext.Current.KeyPairRepository.GetDictionaries(application.Id, dictionaryName, 0, 1).FirstOrDefault();
if (dictionary == null) throw new Exception("Unable to find dictionary");
return new KeyPairEntity()
{
ItemValue = RepositoryContext.Current.KeyPairRepository.GetByKey(dictionary.Id, key)
};


}
catch (Exception err)
{
_logger.Error(err);
throw err;
}

}

}
}
7 changes: 7 additions & 0 deletions Wlog.Web/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@
<allow users="?,*" />
</authorization>
</system.web>
</location>
<location path="api/dictionary">
<system.web>
<authorization>
<allow users="?,*" />
</authorization>
</system.web>
</location>
<location path="Install">
<system.web>
Expand Down
1 change: 1 addition & 0 deletions Wlog.Web/Wlog.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
<Compile Include="Areas\HelpPage\SampleGeneration\SampleDirection.cs" />
<Compile Include="Areas\HelpPage\SampleGeneration\TextSample.cs" />
<Compile Include="Areas\HelpPage\XmlDocumentationProvider.cs" />
<Compile Include="Code\API\DictionaryController.cs" />
<Compile Include="Code\Authentication\ApplicationContext.cs" />
<Compile Include="Code\Enums\ButtonCommands.cs" />
<Compile Include="Code\Enums\ManageMessageId.cs" />
Expand Down

0 comments on commit 31b28ce

Please sign in to comment.