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.Linq.Expressions; | |
| using Microsoft.EntityFrameworkCore; | |
| using TodoApp.Api.Models.Common; | |
| namespace TodoApp.Api.Brokers.EntityStorage.Users; | |
| /// <summary> | |
| /// Provides entity storage operations using Entity Framework Core | |
| /// </summary> | |
| public sealed class EfCoreEntityStorageBroker : DbContext |
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
| /// <summary> | |
| /// Provides common business logic for manipulating entities | |
| /// </summary> | |
| /// <typeparam name="TEntity">Entity type</typeparam> | |
| public class EntityServiceBase<TEntity> : IEntityServiceBase<TEntity> where TEntity : class, IEntity, IQueryableEntity | |
| { | |
| private readonly IEntityRepositoryBase<TEntity> EntityRepository; | |
| public EntityServiceBase(IEntityRepositoryBase<TEntity> entityRepository) | |
| { |
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
| /// <summary> | |
| /// Represents Universal Unique Identifier | |
| /// </summary> | |
| public class UUID | |
| { | |
| /// <summary> | |
| /// Digits used for checksum | |
| /// </summary> | |
| private static int ChecksumDigits = 4; |
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
| /// <summary> | |
| /// Defines methods for Email and SMTP client operations | |
| /// </summary> | |
| public interface IEmailService | |
| { | |
| /// <summary> | |
| /// Creates SMTP client | |
| /// </summary> | |
| /// <param name="emailConfiguration">Email configuration for SMTP host server</param> | |
| /// <returns>Created SMTP client</returns> |
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
| /// <summary> | |
| /// Provides methods for Email and SMTP client operations | |
| /// </summary> | |
| public class EmailService : IEmailService | |
| { | |
| public async Task<SmtpClient> CreateClientAsync(EmailConfiguration emailConfiguration) | |
| { | |
| if (_emailConfiguration == null) | |
| throw new InvalidOperationException(); |
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 static async Task<byte[]> ToZipAsync(this IEnumerable<UploadFile> uploadfiles) | |
| { | |
| if (uploadfiles == null || uploadfiles.Count() == 0) | |
| throw new ArgumentException(); | |
| return await Task.Run(() => | |
| { | |
| // Create streams | |
| using var memoryStream = new MemoryStream(); | |
| using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true)) |
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 TextInputFormatter : InputFormatter | |
| { | |
| private string _mimeType = "text/plain"; | |
| public TextInputFormatter() | |
| { | |
| SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse(_mimeType)); | |
| } | |
| public override bool CanRead(InputFormatterContext context) => context.HttpContext.Request.ContentType?.StartsWith(_mimeType) ?? false; |
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
| declare @TableName sysname = 'TableName' | |
| declare @Result varchar(max) = 'public class ' + @TableName + ' | |
| {' | |
| select @Result = @Result + ' | |
| public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; } | |
| ' | |
| from | |
| ( | |
| select |
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
| /// <summary> | |
| /// Provides extension methods to create complex queries | |
| /// </summary> | |
| public static class QueryExtensions | |
| { | |
| #region Querying | |
| /// <summary> | |
| /// Applies given query options to query source | |
| /// </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
| using System.Linq.Expressions; | |
| using System.Reflection; | |
| using Cerulean.DAL.Models.Query; | |
| namespace Cerulean.DAL.Extensions; | |
| public static class TypeExtensions | |
| { | |
| public static MethodInfo GetCompareMethod(this Type type) | |
| { |
OlderNewer