public void SetCardChargeRequestModel() { cardRequestModel = new CardRequestModel() { amount = (double)PaidAmount, merchantCode = _configuration.GetSection("CustomerSettings").GetSection("merchantCode").Value, description = _configuration.GetSection("CustomerSettings").GetSection("description").Value, customerMobile = _configuration.GetSection("CustomerSettings").GetSection("customerMobile").Value, customerProfileId = _configuration.GetSection("CustomerSettings").GetSection("customerProfileId").Value, customerEmail = _configuration.GetSection("CustomerSettings").GetSection("customerEmail").Value, paymentMethod = "CARD", //_configuration.GetSection("CustomerSettings").GetSection("paymentMethod").Value, currencyCode = _configuration.GetSection("CustomerSettings").GetSection("currencyCode").Value, merchantRefNum = _configuration.GetSection("CustomerSettings").GetSection("merchantRefNum").Value, paymentExpiry = _configuration.GetSection("CustomerSettings").GetSection("paymentExpiry").Value, signature = _configuration.GetSection("CustomerSettings").GetSection("signature").Value, chargeItems = new List <chargeItem>() { new chargeItem() { itemId = _configuration.GetSection("CustomerSettings").GetSection("chargeItems").GetSection("itemId").Value, description = _configuration.GetSection("CustomerSettings").GetSection("chargeItems").GetSection("description").Value, price = 20.50, //_configuration.GetSection("CustomerSettings").GetSection("chargeItems").GetSection("price").Value, quantity = 1 // _configuration.GetSection("CustomerSettings").GetSection("chargeItems").GetSection("quantity").Value } } }; cardRequestModel.signature = GenerateSignature(); }
public HttpResponseMessage SaveCustomerCardRequest([FromBody] CardRequestModel cardRequestModel) { try { CardRequest cardRequest = new CardRequest(); cardRequest.CustomerID = cardRequestModel.CustomerID; cardRequest.CardType = Enum.GetName(typeof(StatusUtil.CardType), cardRequestModel.CardTypeID); cardRequest.RequestType = Enum.GetName(typeof(StatusUtil.RequestType), cardRequestModel.RequestTypeID); cardRequest.PickupBranchID = cardRequestModel.PickupBranchID; cardRequest.Status = StatusUtil.CardStatus.Approved.ToString(); cardRequest.ModifiedDate = System.DateTime.Now; cardRequest.SerialNumber = cardRequestModel.SerialNumber; string username = cardRequestModel.Username; bool result = CustomerPL.SaveCardRequest(cardRequest, username); return(result.Equals(true) ? Request.CreateResponse(HttpStatusCode.OK, "Successful") : Request.CreateResponse(HttpStatusCode.BadRequest, "Request failed")); } catch (Exception ex) { ErrorHandler.WriteError(ex); var response = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); return(response); } }
public async Task <IEnumerable <Models.Card> > Get([FromQuery] int skip, [FromQuery] int?take, [FromQuery] string position, [FromQuery] string notIn = null) { var req = new CardRequestModel() { Skip = skip, Take = take ?? 10, PositionPriority = position, NotIn = notIn?.Split(";")?.Select(x => new Guid(x)) }; var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; //TODO move to currentUserContext return(await _cardService.GetAllAsync(req, userId)); }
public async Task <IHttpActionResult> GetAllCards(CardRequestModel cardsRequest) { if (cardsRequest == null || !ModelState.IsValid) { return(BadRequest("Requires object with list of providerIds")); } var cards = await _cardsService.GetAllCards(); return(Ok(cards)); }
public async Task <IEnumerable <Models.Card> > GetAllAsync(CardRequestModel req, string userId) { var query = _cards.AsQueryable().Where(x => x.UserId == userId); if (req.NotIn != null && req.NotIn.Any()) { query = query.Where(x => !req.NotIn.Contains(x.Id)); } var results = await query.ToListAsync(); return(results.OrderByDescending(x => x.Position == req.PositionPriority).ThenByDescending(x => x.Rating).Skip(req.Skip).Take(req.Take)); }
public async Task <IActionResult> Create(CardRequestModel cardRqModel) { var user = await userManager.GetUser(User); var cardSameFront = await repository.Card .QueryByFront(user.Id, cardRqModel.Front) .FirstOrDefaultAsync(); if (cardSameFront != null && (!cardSameFront.Public || cardSameFront.Approved)) { ModelState.AddModelError("Front", "The front is taken."); return(BadRequest(ModelState)); } var userIsAdmin = await userManager.CheckAdminRole(user); var now = DateTime.Now; if (cardSameFront == null) { cardSameFront = new Card() { Front = cardRqModel.Front.Trim(), Public = userIsAdmin, Approved = userIsAdmin, CreatedDate = now, LastModifiedDate = now, OwnerId = user.Id, AuthorId = user.Id }; repository.Card.Create(cardSameFront); } else { cardSameFront.Front = cardRqModel.Front.Trim(); cardSameFront.Public = true; cardSameFront.Approved = true; cardSameFront.CreatedDate = now; cardSameFront.LastModifiedDate = now; } await repository.SaveChangesAsync(); return(CreatedAtAction(nameof(GetCardById), new { Id = cardSameFront.Id }, new { Message = "Created Successfully.", Id = cardSameFront.Id })); }
public async Task <IActionResult> Update(int id, CardRequestModel cardRqModel) { var user = await userManager.GetUser(User); var existingCard = await repository.Card .QueryById(user.Id, id) .FirstOrDefaultAsync(); if (existingCard == null) { return(NotFound()); } var cardSameFront = await repository.Card .QueryByFront(user.Id, cardRqModel.Front) .AsNoTracking() .FirstOrDefaultAsync(); if (cardSameFront != null && cardSameFront.Id != existingCard.Id) { ModelState.AddModelError("Front", "The front is taken."); return(BadRequest(ModelState)); } var notChanged = existingCard.Front.ToLower() == cardRqModel.Front.Trim().ToLower(); existingCard.Front = cardRqModel.Front.Trim(); existingCard.LastModifiedDate = DateTime.Now; var decks = await repository.Deck .QueryByCardId(existingCard.Id) .ToListAsync(); var userIsAdmin = await userManager.CheckAdminRole(user); foreach (var deck in decks) { deck.Approved = deck.Approved && (userIsAdmin || notChanged); } await repository.SaveChangesAsync(); return(NoContent()); }
public async Task <IEnumerable <Models.Card> > GetAllAsync(CardRequestModel req, string userId) { req.PositionPriority = PositionMap(req.PositionPriority); return(await _cardRepository.GetAllAsync(req, userId)); }