| | | 1 | | using Microsoft.EntityFrameworkCore; |
| | | 2 | | using Microsoft.Extensions.Logging; |
| | | 3 | | using System.Collections.Generic; |
| | | 4 | | using System.Linq; |
| | | 5 | | using System.Threading.Tasks; |
| | | 6 | | using WinSolutions.Sveta.Server.Data.DataModel.Contexts; |
| | | 7 | | using WinSolutions.Sveta.Server.Data.DataModel.Entities; |
| | | 8 | | using WinSolutions.Sveta.Server.Services.Interfaces; |
| | | 9 | | using WinSolutions.Sveta.Common; |
| | | 10 | | using WinSolutions.Sveta.Common.Extensions; |
| | | 11 | | using WinSolutions.Sveta.Server.Data.DataModel.Kinds; |
| | | 12 | | |
| | | 13 | | namespace WinSolutions.Sveta.Server.Services.Implements |
| | | 14 | | { |
| | | 15 | | public class DirectoriesService : SvetaServiceBase, IDirectoriesService |
| | | 16 | | { |
| | | 17 | | private readonly SvetaDbContext _db; |
| | | 18 | | private readonly ILogger<IDirectoriesService> _logger; |
| | | 19 | | |
| | | 20 | | public DirectoriesService(SvetaDbContext db, ILogger<IDirectoriesService> logger, IAuthenticationService authent |
| | 186 | 21 | | : base(authenticationService) |
| | 186 | 22 | | { |
| | 186 | 23 | | _db = db; |
| | 186 | 24 | | _logger = logger; |
| | 186 | 25 | | } |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// получить валюту |
| | | 29 | | /// </summary> |
| | | 30 | | /// <param name="id">id валюты</param> |
| | | 31 | | /// <returns></returns> |
| | 0 | 32 | | public async Task<Currency> GetCurrency(long id) => await _db.refCurrency.Where(e => !e.IsDeleted).FirstOrDefaul |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// Получить список валют |
| | | 36 | | /// </summary> |
| | | 37 | | /// <param name="filter">фильтр по Name, Code, StrCode</param> |
| | | 38 | | /// <returns></returns> |
| | 0 | 39 | | public async Task<List<Currency>> GetCurrencies(string filter = null) => await _db.refCurrency |
| | 0 | 40 | | .AsNoTracking() |
| | 0 | 41 | | .Include(d => d.RecState) |
| | 0 | 42 | | .Where(d => !d.IsDeleted) |
| | 0 | 43 | | .Where(x => (filter!= null ? x.NAME.ToUpper().Contains(filter.ToUpper()) || x.CODE.ToUpper().Contains(filter |
| | 0 | 44 | | .ToListAsync(); |
| | | 45 | | |
| | | 46 | | /// <summary> |
| | | 47 | | ///Получить тип контрагента |
| | | 48 | | /// </summary> |
| | | 49 | | /// <param name="id">id типа контрагента</param> |
| | | 50 | | /// <returns></returns> |
| | 0 | 51 | | public async Task<ContragentsKind> GetContragentKind(long id) => await _db.refContragentsKind.Where(e => !e.IsDe |
| | | 52 | | /// <summary> |
| | | 53 | | ///Получить тип события |
| | | 54 | | /// </summary> |
| | | 55 | | /// <param name="id">id типа события</param> |
| | | 56 | | /// <returns></returns> |
| | 0 | 57 | | public async Task<EventsKind> GetEventKind(long id) => await _db.refEventsKind.Where(e => !e.IsDeleted).FirstOrD |
| | | 58 | | /// <summary> |
| | | 59 | | ///Получить статус нотификации |
| | | 60 | | /// </summary> |
| | | 61 | | /// <param name="id">id статуса</param> |
| | | 62 | | /// <returns></returns> |
| | 745 | 63 | | public async Task<NotificationsStatus> GetNotificationStatus(long id) => await _db.refNotificationsStatus.Where( |
| | | 64 | | /// <summary> |
| | | 65 | | /// Получить тип нотификации |
| | | 66 | | /// </summary> |
| | | 67 | | /// <param name="id">id типа</param> |
| | | 68 | | /// <returns></returns> |
| | 745 | 69 | | public async Task<NotificationsType> GetNotificationType(long id) => await _db.refNotificationsType.Where(e => ! |
| | | 70 | | /// <summary> |
| | | 71 | | /// получить тип служебной записи RecordState |
| | | 72 | | /// </summary> |
| | | 73 | | /// <param name="id">id типа</param> |
| | | 74 | | /// <returns></returns> |
| | 2222 | 75 | | public async Task<RecordsState> GetRecordState(long id) => await _db.refRecordsState.Where(e => !e.IsDeleted).Fi |
| | | 76 | | /// <summary> |
| | | 77 | | /// Получить единицу измерения |
| | | 78 | | /// </summary> |
| | | 79 | | /// <param name="id">id единицы измерения</param> |
| | | 80 | | /// <returns></returns> |
| | 0 | 81 | | public async Task<UnitsKind> GetUnitKind(long id) => await _db.refUnitsKind.Where(e => !e.IsDeleted).FirstOrDefa |
| | | 82 | | /// <summary> |
| | | 83 | | /// Получить единицу измерения |
| | | 84 | | /// </summary> |
| | | 85 | | /// <param name="name">наименование единицы измерения</param> |
| | | 86 | | /// <returns></returns> |
| | | 87 | | public async Task<UnitsKind> GetUnitKind(string name) => |
| | 0 | 88 | | await _db.refUnitsKind.FirstOrDefaultAsync(d => !d.IsDeleted && d.Name.ToLower().Equals(name.NormalizeName() |
| | | 89 | | /// <summary> |
| | | 90 | | /// Получить единицу измерения |
| | | 91 | | /// </summary> |
| | | 92 | | /// <param name="code">код единицы измерения</param> |
| | | 93 | | /// <returns></returns> |
| | 0 | 94 | | public async Task<UnitsKind> GetUnitKindByCode(int code) => await _db.refUnitsKind.Where(e => !e.IsDeleted).Firs |
| | | 95 | | /// <summary> |
| | | 96 | | /// Получить тип НДС |
| | | 97 | | /// </summary> |
| | | 98 | | /// <param name="id">id типа</param> |
| | | 99 | | /// <returns></returns> |
| | 0 | 100 | | public async Task<VatsKind> GetVatKind(long id) => await _db.refVatsKind.Where(e => !e.IsDeleted).FirstOrDefault |
| | | 101 | | /// <summary> |
| | | 102 | | /// Получить тип НДС |
| | | 103 | | /// </summary> |
| | | 104 | | /// <param name="code">код типа</param> |
| | | 105 | | /// <returns></returns> |
| | 0 | 106 | | public async Task<VatsKind> GetVatKindByCode(int code) => await _db.refVatsKind.Where(e => !e.IsDeleted).FirstOr |
| | | 107 | | /// <summary> |
| | | 108 | | /// Получить статус документа |
| | | 109 | | /// </summary> |
| | | 110 | | /// <param name="id">id статуса</param> |
| | | 111 | | /// <returns></returns> |
| | 0 | 112 | | public async Task<MovementStatus> GetMovementStatus(long id) => await _db.refMovementStatus.Where(e => !e.IsDele |
| | | 113 | | /// <summary> |
| | | 114 | | /// Получить тип документа |
| | | 115 | | /// </summary> |
| | | 116 | | /// <param name="id">id типа</param> |
| | | 117 | | /// <returns></returns> |
| | 1 | 118 | | public async Task<MovementType> GetMovementType(long id) => await _db.refMovementType.Where(e => !e.IsDeleted).F |
| | | 119 | | /// <summary> |
| | | 120 | | /// Получить список типо доставки |
| | | 121 | | /// </summary> |
| | | 122 | | /// <returns></returns> |
| | 186 | 123 | | public async Task<List<DeliveryType>> GetDeliveryTypes() => await _db.DeliveryTypes |
| | 186 | 124 | | .Include(x => x.DeliveryCostTypes) |
| | 186 | 125 | | .Include(x => x.RecState) |
| | 186 | 126 | | .AsNoTracking() |
| | 186 | 127 | | .Where(d => !d.IsDeleted).ToListAsync(); |
| | | 128 | | /// <summary> |
| | | 129 | | /// получить тип доставки |
| | | 130 | | /// </summary> |
| | | 131 | | /// <param name="id">id типа</param> |
| | | 132 | | /// <returns></returns> |
| | 44 | 133 | | public async Task<DeliveryType> GetDeliveryType(long id) => await _db.DeliveryTypes |
| | 44 | 134 | | .Include(x => x.DeliveryCostTypes) |
| | 44 | 135 | | .Include(x => x.RecState) |
| | 44 | 136 | | .FirstOrDefaultAsync(d => !d.IsDeleted && d.Id == id); |
| | | 137 | | |
| | | 138 | | /// <summary> |
| | | 139 | | /// Получает список видов событий |
| | | 140 | | /// </summary> |
| | | 141 | | /// <returns>список объектов EnumDTO</returns> |
| | 0 | 142 | | public async Task<List<EventsKind>> GetEventKinds() => await _db.refEventsKind.Where(e => !e.IsDeleted).ToListAs |
| | | 143 | | } |
| | | 144 | | } |