Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public IActionResult CreateCheckInWithFailure(OfficeCheckInCreateRequest movement)
- {
- var failure = _dbContext.Failures.FirstOrDefault(x => x.Id.Equals(movement.FailureId));
- if (!movement.Failed || failure == null)
- return new BadRequestObjectResult("Invalid Request");
- var originOffice = _dbContext.Offices
- .FirstOrDefault(x => x.Id.Equals(movement.OriginId));
- if (originOffice == null || originOffice.IsFund)
- return new BadRequestObjectResult("Invalid Origin");
- var fund = _dbContext.OfficesAndFunds
- .Where(x => x.CustomerId.Equals(movement.DestinationId))
- .FirstOrDefault(x => x.OfficeId.Equals(movement.DestinationId));
- if (fund == null || fund.ClosedAt.CompareTo(movement.ServiceDate) >= 0)
- return new NotFoundObjectResult("No Funds Were Found");
- _dbContext.Movements.Add(_mapper.Map<Movement>(movement));
- _dbContext.SaveChanges();
- return new OkObjectResult("Movement processed successfully");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement