| | | 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 | | |
| | | 11 | | namespace WinSolutions.Sveta.Server.Services.Implements |
| | | 12 | | { |
| | | 13 | | public class MovementTypeStatusService : SvetaServiceBase, IMovementTypeStatusService |
| | | 14 | | { |
| | | 15 | | private readonly SvetaDbContext _db; |
| | | 16 | | private readonly ILogger<MovementTypeStatusService> _logger; |
| | | 17 | | |
| | | 18 | | public MovementTypeStatusService(SvetaDbContext db, ILogger<MovementTypeStatusService> logger, IAuthenticationSe |
| | 139 | 19 | | : base(authenticationService) |
| | 139 | 20 | | { |
| | 139 | 21 | | _db = db; |
| | 139 | 22 | | _logger = logger; |
| | 139 | 23 | | } |
| | | 24 | | |
| | 176 | 25 | | public async Task<MovementStatus> GetStatus(MovementType type, string code) => await _db.refMovementStatus |
| | 176 | 26 | | .Include(d => d.StatusOwner) |
| | 176 | 27 | | .Include(d => d.MovementType) |
| | 176 | 28 | | .Where(d => d.MovementTypeId == type.Id) |
| | 176 | 29 | | .FirstOrDefaultAsync(d => d.Code.ToUpper().Equals(code.ToUpper())); |
| | | 30 | | |
| | 67 | 31 | | public async Task<MovementStatus> GetMovementStatus(long id) => await _db.refMovementStatus |
| | 67 | 32 | | .FirstOrDefaultAsync(d => !d.IsDeleted && d.Id == id); |
| | | 33 | | |
| | 0 | 34 | | public async Task<List<MovementStatus>> GetMovementStatuses(long movementTypeId) => await _db.refMovementStatus |
| | 0 | 35 | | .Include(d => d.RecState) |
| | 0 | 36 | | .Include(d => d.MovementType) |
| | 0 | 37 | | .Where(d => !d.IsDeleted) |
| | 0 | 38 | | .Where(d => d.MovementTypeId == movementTypeId) |
| | 0 | 39 | | .ToListAsync(); |
| | 0 | 40 | | public async Task<List<MovementStatus>> GetMovementStatuses(long typeId, string filter="") => await _db.refMovem |
| | 0 | 41 | | .Include(d => d.RecState) |
| | 0 | 42 | | .Include(d => d.MovementType) |
| | 0 | 43 | | .Where(d => !d.IsDeleted) |
| | 0 | 44 | | .Where(d => typeId == 0 || d.MovementType.Id == typeId) |
| | 0 | 45 | | .Where(d => string.IsNullOrEmpty(filter) || |
| | 0 | 46 | | (d.Name.ToUpper().Contains(filter.ToUpper()) |
| | 0 | 47 | | || d.Code.ToUpper().Contains(filter.ToUpper()) |
| | 0 | 48 | | || d.MovementType.Name.ToUpper().Contains(filter.ToUpper()))) |
| | 0 | 49 | | .OrderBy(d => d.Id).ToListAsync(); |
| | | 50 | | |
| | 277 | 51 | | public async Task<MovementType> GetMovementType(long typeId) => await _db.refMovementType |
| | 277 | 52 | | .Include(d => d.RecState) |
| | 277 | 53 | | .FirstOrDefaultAsync(d => !d.IsDeleted && d.Id == typeId); |
| | | 54 | | |
| | | 55 | | public async Task<List<MovementType>> GetMovementTypes(string filter="") |
| | 0 | 56 | | { |
| | 0 | 57 | | var list = _db.refMovementType |
| | 0 | 58 | | .Include(d => d.RecState) |
| | 0 | 59 | | .Where(d => !d.IsDeleted); |
| | 0 | 60 | | if (!string.IsNullOrWhiteSpace(filter)) |
| | 0 | 61 | | { |
| | 0 | 62 | | list = list.Where(d => d.Name.ToUpper().Contains(filter.ToUpper()) || d.Code.ToUpper().Contains(filter.T |
| | 0 | 63 | | } |
| | | 64 | | |
| | 0 | 65 | | return await list.OrderBy(d => d.Id).ToListAsync(); |
| | 0 | 66 | | } |
| | | 67 | | } |
| | | 68 | | } |