Skip to content

Instantly share code, notes, and snippets.

View hikalkan's full-sized avatar

Halil İbrahim Kalkan hikalkan

View GitHub Profile
@hikalkan
hikalkan / MyJob1Class.cs
Created July 12, 2016 11:01
Example usage of HangFire's RecurringJob in ABP
using Abp.Dependency;
using Castle.Core.Logging;
namespace Halil.HangfireTests.Web.Controllers
{
public class MyJob1Class : ITransientDependency
{
private readonly ILogger _logger;
public MyJob1Class(ILogger logger)
@hikalkan
hikalkan / AbpSessionExtensions.cs
Created June 20, 2016 16:06
Creating an overridable session for ABP
using System;
using Abp.Runtime.Session;
namespace Abp.Temp
{
public static class AbpSessionExtensions
{
public static IDisposable Override(this IAbpSession abpSession, int? tenantId, long? userId)
{
var overridableSession = abpSession as OverridableSession;
using System;
using System.IO;
using System.Linq;
using System.Text;
namespace AbpWebSite.Templates
{
/// <summary>
/// Used to rename a solution
/// </summary>
@hikalkan
hikalkan / MyDbContextTypeMatcher.cs
Last active June 11, 2016 20:48
DbContextTypeMatcher test
using System;
using System.Collections.Generic;
using System.Linq;
using Abp.Collections.Extensions;
using Abp.Dependency;
using Abp.Domain.Uow;
using Abp.EntityFramework.Repositories;
using Abp.MultiTenancy;
namespace Abp.EntityFramework
@hikalkan
hikalkan / AbpZeroDbModelBuilderExtensions.cs
Created March 2, 2016 12:54
Change prefix ABP tables.
using System.Data.Entity;
using Abp.Application.Editions;
using Abp.Application.Features;
using Abp.Auditing;
using Abp.Authorization;
using Abp.Authorization.Roles;
using Abp.Authorization.Users;
using Abp.BackgroundJobs;
using Abp.Configuration;
using Abp.Localization;
@hikalkan
hikalkan / INotificationManager.cs
Created January 14, 2016 11:44
A persistent notification manager interface draft (to be added to ABP)
public interface INotificationManager
{
/// <summary>
/// Subscribes a user to a notificationName for any event.
/// </summary>
void Subscribe(long userId, string notificationName);
/// <summary>
/// Subscribes a user to a notificationName for events on specific Entity type.
/// </summary>
@hikalkan
hikalkan / AccountController.cs
Created January 13, 2016 16:25
Adding a new property to session
//Add new property to claims on login
private async Task SignInAsync(User user, ClaimsIdentity identity = null, bool rememberMe = false)
{
if (identity == null)
{
identity = await _userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
}
identity.AddClaim(new Claim("Application_UserEmail", user.EmailAddress)); //SETTING NEW PROPERTY
@hikalkan
hikalkan / Global.asax.cs
Created January 2, 2016 21:52
Enabling Serilog in an ABP based Web project
//Remove this:
AbpBootstrapper.IocManager.IocContainer
.AddFacility<LoggingFacility>(f => f.UseLog4Net()
.WithConfig("log4net.config")
);
//Add this:
AbpBootstrapper.IocManager.IocContainer.Register(
@hikalkan
hikalkan / AccountController.cs
Last active March 20, 2020 07:10
User Impersonation for ASP.NET Boilerplate
/* SAMPLE AJAX CALL to this action:
(This is enough since it's automatically redirected to the target tenant's ImpersonateSignIn action)
abp.ajax({
url: abp.appPath + 'Account/Impersonate',
data: JSON.stringify({
tenantId: 1, //Target tenant id (can be null if target user is a host user)
userId: 2 //Target user id
})
@hikalkan
hikalkan / CallApiFromConsole-Program.cs
Last active August 16, 2022 22:16
This code shows how to login to an ASP.NET ZERO (http://aspnetzero.com) based application and call an application service method remotely.
using System;
using System.Net;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Abp;
using Abp.Application.Services.Dto;
using Abp.Dependency;
using Abp.Domain.Entities.Auditing;
using Abp.Extensions;