public IDataResult <Guid> Add(DebitForAddDto debitForAddDto)
        {
            var fixture = fixtureService.GetById(debitForAddDto.FixtureId).Data;

            if (fixture.FixturePositionId != (short)FixturePositions.Position.Available)
            {
                throw new LogicException(Messages.DebitFixturePosIsNotAvailable);
            }

            var debit = new Debit()
            {
                CreatedAt   = DateTime.Now,
                DateDebit   = debitForAddDto.DateDebit,
                DateReturn  = DateTime.MaxValue,
                Description = debitForAddDto.Description,
                FixtureId   = debitForAddDto.FixtureId,
                IsReturn    = false,
                UpdatedAt   = DateTime.Now,
                UserId      = debitForAddDto.UserId
            };

            debitDal.Add(debit);

            fixtureService.UpdatePosition(debitForAddDto.FixtureId, FixturePositions.Position.Debit);
            return(new SuccessDataResult <Guid>(debit.Id, Messages.DebitAdded));
        }
Пример #2
0
        public IActionResult GetById(Guid id)
        {
            var result = fixtureService.GetById(id);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result.Message));
        }