Skip to content

Commit

Permalink
update lib ref to 2.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
nhathoang989 committed Sep 16, 2018
1 parent 4df3ae8 commit e9b51a4
Show file tree
Hide file tree
Showing 6 changed files with 2,426 additions and 33 deletions.
52 changes: 28 additions & 24 deletions src/Swastika/Common/Helper/CommonHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,31 +302,35 @@ public static void WriteBytesToFile(string fullPath, string strBase64)
}
}

//TODO: Still need?
//public static string UploadPhoto(string fullPath, Image img)
//{
// try
// {
// if (!Directory.Exists(fullPath))
// {
// Directory.CreateDirectory(fullPath);
// }
public static string ConvertCaseString(string phrase, Case cases)
{
string[] splittedPhrase = phrase.Split(' ', '-', '.');
var sb = new StringBuilder();

// if (img != null)
// {
// //string fileExt = GetFilenameExtension(img.RawFormat);
// //file_name = (guid + fileExt).Trim();
// //file_dir = filePath + file_name;
// //ImageResizer.ResizeStream(TTXConstants.Params.photoSize, img, file_dir);
if (cases == Case.CamelCase)
{
//splittedPhrase[0] = string.Empty;
}
else if (cases == Case.PascalCase)
sb.Append(splittedPhrase[0].ToLower());


// return ImageHelper.ResizeImage(img, fullPath);
// }
// }
// catch (Exception ex) // TODO: Add more specific exeption types instead of Exception only
// {
// return string.Empty;
// }
// return string.Empty;
//}
foreach (String s in splittedPhrase)
{
char[] splittedPhraseChars = s.ToCharArray();
if (splittedPhraseChars.Length > 0)
{
splittedPhraseChars[0] = ((new String(splittedPhraseChars[0], 1)).ToUpper().ToCharArray())[0];
}
sb.Append(new String(splittedPhraseChars));
}
return sb.ToString();
}

public enum Case
{
PascalCase,
CamelCase
}
}
}
61 changes: 61 additions & 0 deletions src/Swastika/Domain/Core/Repository/DefaultEcmRepositories.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Licensed to the Swastika I/O Foundation under one or more agreements.
// The Swastika I/O Foundation licenses this file to you under the GNU General Public License v3.0.
// See the LICENSE file in the project root for more information.

using Microsoft.EntityFrameworkCore;
using System;

namespace Swastika.Domain.Data.Repository
{
/// <summary>
/// Default Repository with view
/// </summary>
/// <typeparam name="TDbContext">The type of the database context.</typeparam>
/// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TView">The type of the view.</typeparam>
/// <seealso cref="Swastika.Domain.Data.Repository.ModelRepositoryBase{TContext, TModel}" />
public class EcmDefaultRepository<TDbContext, TModel, TView> :
Swastika.Domain.Data.Repository.EcmViewRepositoryBase<TDbContext, TModel, TView>
where TDbContext : DbContext
where TModel : class
where TView : Swastika.Domain.Data.ViewModels.EcmViewModelBase<TDbContext, TModel, TView>
{
/// <summary>
/// The instance
/// </summary>
private static volatile EcmDefaultRepository<TDbContext, TModel, TView> instance;

/// <summary>
/// The synchronize root
/// </summary>
private static readonly object syncRoot = new Object();

/// <summary>
/// Prevents a default instance of the <see cref="DefaultRepository{TDbContext, TModel, TView}"/> class from being created.
/// </summary>
private EcmDefaultRepository()
{
}

/// <summary>
/// Gets the instance.
/// </summary>
/// <value>
/// The instance.
/// </value>
public static EcmDefaultRepository<TDbContext, TModel, TView> Instance {
get {
if (instance == null)
{
lock (syncRoot)
{
if (instance == null)
instance = new EcmDefaultRepository<TDbContext, TModel, TView>();
}
}

return instance;
}
}
}
}
Loading

0 comments on commit e9b51a4

Please sign in to comment.