This file contains 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
//We have to define our application first | |
var myApp=angular.module("toDoList", []); | |
/*Controller is like a brain of our app. It contain models and logics required | |
to operate our to do list. | |
*/ | |
myApp.controller("toDoListCtrl", ['$scope', | |
function($scope) { | |
//A model holding tasks | |
$scope.taskList = []; |
This file contains 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 abstract class BaseController<T> : Controller where T : BaseController<T> | |
{ | |
private DbCachingService _dbCs; | |
protected DbCachingService DbCS => _dbCs?? (_dbCs= (DbCachingService)HttpContext.RequestServices.GetService(typeof (DbCachingService))); | |
private ApplicationDbContext _dbContext; | |
protected ApplicationDbContext DbContext => _dbContext ?? (_dbContext = (ApplicationDbContext)HttpContext.RequestServices.GetService(typeof(ApplicationDbContext))); | |
This file contains 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
/* usage | |
* ключи обязательно должны быть id или name полей | |
если не указаны - отображается только ValidationSummary | |
showErrors($form, | |
{ | |
"Email": "bad email", | |
"CompanyName": "bad company name" | |
} | |
); |
This file contains 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 ConfigureServices(IServiceCollection services) | |
{ | |
services.AddCors(); | |
// Add framework services. | |
services.AddDbContext<ApplicationDbContext>(options => | |
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); | |
services.AddIdentity<ApplicationUser, IdentityRole>() | |
.AddEntityFrameworkStores<ApplicationDbContext>() |
This file contains 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
/// <summary> | |
/// Такой аттрибут надо явно регистрировать в контейнере зависимостей | |
/// синтаксис использования [ServiceFilter(typeof(SomeActionFilter))] | |
/// </summary> | |
public class SomeActionFilter: ActionFilterAttribute | |
{ | |
private ApplicationDbContext _appDbContext; | |
public SomeActionFilter(ApplicationDbContext appDbContext) | |
{ |
This file contains 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 MemoryCacheManager | |
{ | |
#region Fields | |
private readonly IMemoryCache _cache; | |
/// <summary> | |
/// All keys of cache | |
/// </summary> | |
/// <remarks>Dictionary value indicating whether a key still exists in cache</remarks> |
This file contains 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
select prRemote.*,prLocal.* from [193.107.181.75].YstTerminal.dbo.Producers prRemote full outer join YstTerminal.dbo.Producers prLocal | |
on prRemote.Producerid=prLocal.Producerid | |
where prRemote.producerid is null or prLocal.ProducerId is null | |
/* | |
select count(*) from [193.107.181.75].YstTerminal.dbo.Producers | |
select count(*) from YstTerminal.dbo.Producers | |
*/ |
This file contains 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
/* | |
* по каждому производителю выбираем 3 топовых продукта | |
* смысл в том что producers.producerid - можем передавать в нижестоящий запрос либо в | |
* нижестоящую функцию возвращающую табличное значение | |
*/ | |
SELECT producers.*, productso.* | |
FROM producers | |
CROSS APPLY | |
( |
This file contains 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
<#@ template debug="false" hostspecific="false" language="C#" #> | |
<#@ assembly name="System.Core" #> | |
<#@ assembly name="System.Xml" #> | |
<#@ import namespace="System.Linq" #> | |
<#@ import namespace="System.Text" #> | |
<#@ import namespace="System.IO" #> | |
<#@ import namespace="System.Xml" #> | |
<#@ import namespace="System.Collections.Generic" #> | |
<#@ output extension=".cs" #> | |
// Данный файл генерирует класс SampleDto в TextTemplate1.cs файле |
This file contains 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 static Expression<Func<TEntity, bool>> CreateExpression<TEntity>(LambdaExpression baseLambda, Expression<Func<TEntity, bool>> filter) where TEntity : class | |
{ | |
var param = baseLambda.Parameters[0]; | |
var left = baseLambda.Body; | |
var right = filter.Body.ReplaceParameter(filter.Parameters[0], param); | |
var result = Expression.AndAlso(left, right); | |
return Expression.Lambda<Func<TEntity, bool>>(result, param); | |
OlderNewer