This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Authorize(Roles = "Administrator")] | |
public ActionResult Impersonate(string email) | |
{ | |
var impersonatedUser = UserManager.FindByEmail(email); | |
var impersonatedIdentity = UserManager.CreateIdentity(impersonatedUser, DefaultAuthenticationTypes.ApplicationCookie); | |
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); | |
AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = false }, impersonatedIdentity); | |
return RedirectToAction("Index", "Home"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.ServiceModel; | |
using System.ServiceModel.Channels; | |
using System.ServiceModel.Description; | |
using System.ServiceModel.Dispatcher; | |
namespace Helper | |
{ | |
public static class ClientMessageInspectorInjector | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void DeleteWhere(Expression<Func<T, bool>> filter) | |
{ | |
var query = DbSet.Where(filter); | |
string selectSql = query.ToString(); | |
string deleteSql = "DELETE [Extent1] " + selectSql.Substring(selectSql.IndexOf("FROM")); | |
var internalQuery = query.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance).Where(field => field.Name == "_internalQuery").Select(field => field.GetValue(query)).First(); | |
var objectQuery = internalQuery.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance).Where(field => field.Name == "_objectQuery").Select(field => field.GetValue(internalQuery)).First() as ObjectQuery; | |
var parameters = objectQuery.Parameters.Select(p => new SqlParameter(p.Name, p.Value)).ToArray(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: Move to Infrastructıre. | |
public static class PredicateBuilder | |
{ | |
public static Expression<Func<T, bool>> True<T>() { return f => true; } | |
public static Expression<Func<T, bool>> False<T>() { return f => false; } | |
public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> expr1, | |
Expression<Func<T, bool>> expr2) | |
{ | |
var invokedExpr = Expression.Invoke(expr2, expr1.Parameters.Cast<Expression>()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace AcerPlatformV2.Business.Services | |
{ | |
public class TransactionService : ITransactionService | |
{ | |
private IDbContextTransaction _transaction; | |
private readonly IUnitOfWork _unitOfWork; | |
public TransactionService(IUnitOfWork unitOfWork) | |
{ | |
_unitOfWork = unitOfWork; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <copyright file="CustomClaimsPrincipalFactory.cs" company=""> | |
// Copyright (c) | |
// </copyright> | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Security.Claims; | |
using System.Threading.Tasks; | |
using Platform.Business.Interfaces; | |
using Platform.Domain.Entities; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Mvc.ModelBinding; | |
using Newtonsoft.Json; | |
using System; | |
using System.Threading.Tasks; | |
namespace AcerPlatformV2.Presentation.Helpers | |
{ | |
/// <summary> | |
/// This model binder resolve a JsonString to A List Of T | |
/// </summary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).on('click', 'button.save', function (event) { | |
$.validator.unobtrusive.parse('#InspectionScopeForm'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GenericRepository<T> : IRepository<T> where T: class | |
{ | |
private readonly DbContext _context; | |
private IDbSet<T> dbSet; | |
public GenericRepository(DbContext context) | |
{ | |
_context = context; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IQueryable<Entity> GetAllIncluding(params Expression<Func<Entity, object>>[] includedProperties) | |
{ | |
IQueryable<Entity> query = db.Groups; | |
foreach (var includedProperty in includedProperties) | |
{ | |
query = query.Include(includedProperty); | |
} | |
return query; | |
} |