Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. public IActionResult CreateCheckInWithFailure(OfficeCheckInCreateRequest movement)
  2. {
  3.     var failure = _dbContext.Failures.FirstOrDefault(x => x.Id.Equals(movement.FailureId));
  4.            
  5.     if (!movement.Failed || failure == null)
  6.         return new BadRequestObjectResult("Invalid Request");
  7.            
  8.     var originOffice = _dbContext.Offices
  9.         .FirstOrDefault(x => x.Id.Equals(movement.OriginId));
  10.  
  11.     if (originOffice == null || originOffice.IsFund)
  12.         return new BadRequestObjectResult("Invalid Origin");
  13.  
  14.     var fund = _dbContext.OfficesAndFunds
  15.         .Where(x => x.CustomerId.Equals(movement.DestinationId))
  16.         .FirstOrDefault(x => x.OfficeId.Equals(movement.DestinationId));
  17.            
  18.     if (fund == null || fund.ClosedAt.CompareTo(movement.ServiceDate) >= 0)
  19.         return new NotFoundObjectResult("No Funds Were Found");
  20.  
  21.     _dbContext.Movements.Add(_mapper.Map<Movement>(movement));
  22.     _dbContext.SaveChanges();
  23.            
  24.     return new OkObjectResult("Movement processed successfully");
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement