public IDPaperInfo GetUserByIDPaper(string content) { IDPaperInfo iDPaperInfo = null; Idpaper idpaper = null; string[] contents = content.Split(" "); foreach (string con in contents) { idpaper = _iDPaperRepository.GetAll().Where(ip => ip.Content == con).FirstOrDefault(); if (idpaper != null) { break; } } //Idpaper idpaper = _iDPaperRepository.GetAll().Where(ip => ip.Content.ToLower().Contains(content)).FirstOrDefault(); if (idpaper != null) { iDPaperInfo = new IDPaperInfo() { UserId = idpaper.CustomerId, AppliedPrice = idpaper.AppliedPrice }; } return(iDPaperInfo); }
public IActionResult PayTicket(int receiverId, string transDetail, string input) { IDPaperInfo iDPaperInfo = _iDPaperService.VerifyIDPaper(input); if (iDPaperInfo.Type == IDPaperConstants.IDPP_INVALID) { return(new JsonResult(IDPaperConstants.IDPP_INVALID) { StatusCode = StatusCodes.Status404NotFound }); } if (iDPaperInfo.Type == IDPaperConstants.IDPP_INACTIVE) { return(new JsonResult(IDPaperConstants.IDPP_INACTIVE) { StatusCode = StatusCodes.Status404NotFound }); } if (iDPaperInfo != null) { decimal amount = iDPaperInfo.AppliedPrice; bool isPayable = _walletService.CheckPayable(iDPaperInfo.UserId, amount); if (!isPayable) { return(new JsonResult(PaymentConstants.INVALID_BALANCE) { StatusCode = StatusCodes.Status404NotFound }); } var transaction = _walletService.PayTransaction(iDPaperInfo.UserId, receiverId, amount, transDetail); if (transaction == null) { return(new JsonResult(PaymentConstants.TRANS_FAIL) { StatusCode = StatusCodes.Status404NotFound }); } return(new JsonResult(PaymentConstants.TRANS_SUCESSFULL) { StatusCode = StatusCodes.Status200OK }); } return(new JsonResult(PaymentConstants.TRANS_FAIL) { StatusCode = StatusCodes.Status404NotFound }); }
public IActionResult GetUserInfoByIDPaper(string content) { IDPaperInfo result = _idPaperService.GetUserByIDPaper(content); if (result != null) { return(new JsonResult(result) { StatusCode = StatusCodes.Status200OK }); } return(new JsonResult(result) { StatusCode = StatusCodes.Status404NotFound }); }
public IDPaperInfo VerifyIDPaper(string input) { IDPaperInfo result = null; string[] inputs = input.Split(" "); Idpaper idpaper = _iDPaperRepository.GetAll().Where(ip => inputs.Any(val => ip.Content.Contains(val))).FirstOrDefault(); if (idpaper != null) { if (!idpaper.IsValid) { result = new IDPaperInfo() { Type = IDPaperConstants.IDPP_INVALID, UserId = idpaper.CustomerId, AppliedPrice = 0 }; } else if (!idpaper.IsUsing) { result = new IDPaperInfo() { Type = IDPaperConstants.IDPP_INACTIVE, UserId = idpaper.CustomerId, AppliedPrice = 0 }; } else { result = new IDPaperInfo() { Type = idpaper.Type, UserId = idpaper.CustomerId, AppliedPrice = idpaper.AppliedPrice }; } } return(result); }
public List <IDPaperInfo> GetByUserId(int userId) { List <IDPaperInfo> results = null; IDPaperInfo iDPaperInfo = null; List <Idpaper> idpapers = _iDPaperRepository.GetAll().Where(ip => ip.CustomerId == userId).ToList(); if (idpapers != null) { results = new List <IDPaperInfo>(); foreach (var idpp in idpapers) { iDPaperInfo = new IDPaperInfo() { UserId = idpp.CustomerId, AppliedPrice = idpp.AppliedPrice, Type = idpp.Type }; results.Add(iDPaperInfo); } } return(results); }