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));
        }
Example #2
0
 public IResult Add(Debit debit)
 {
     _debitDal.Add(debit);
     return(new SuccessResult(Messages.Added));
 }
 public Debit Add(Debit debit)
 {
     return(_debitDal.Add(debit));
 }