Exemplo n.º 1
0
        public bool DeleteOrder(int id)
        {
            OrderPlace orderPlace = GetOrder(id);

            _productContext.Entry(orderPlace).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
            _productContext.SaveChanges();
            return(true);
        }
Exemplo n.º 2
0
 public void AddOrder(OrderPlace orderPlace)
 {
     try
     {
         _productContext.Orders.Add(orderPlace);
         _productContext.SaveChanges();
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 3
0
        private async Task CreateNewOrderAsync(PaymentRequest request, int userId, OrderPlace orderPlace, OrderPaymentInfo paymentInfo)
        {
            var order = new OrderBaseDto
            {
                UserId          = userId,
                Date            = DateTime.Now,
                ExtOrderId      = new Guid(request.extOrderId),
                NumOfCharges    = Convert.ToInt32(request.products[0].quantity),
                OrderPlace      = orderPlace,
                OrderState      = OrderStatus.Pending,
                PricePerCharge  = paymentInfo.PricePerCharge,
                PriceTresholdId = paymentInfo.PriceTresholdId,
                Price           = paymentInfo.TotalAmount,
            };

            await _orderService.CreateAsync(order);
        }
Exemplo n.º 4
0
        private void SetValues()
        {
            try
            {
                List <Items>      itemsComplete   = new List <Items>();
                List <OrderPlace> _OrderPlaceList = new List <OrderPlace>();
                CN_Products       _CN_Products    = new CN_Products();
                CN_Orders         _CN_Orders      = new CN_Orders();
                BasePage.DataGlobal = _CN_Products.ShowItems();
                foreach (DataRow row in BasePage.DataGlobal.Rows)
                {
                    Items item = new Items
                    {
                        ItemId       = Convert.ToInt32(row["ItemId"].ToString()),
                        ItemCode     = row["ItemCode"].ToString(),
                        Descriptions = row["Descriptions"].ToString(),
                        Field1       = row["Field1"].ToString(),
                        Field2       = row["Field2"].ToString(),
                        Field3       = row["Field3"].ToString(),
                        Price        = Convert.ToDecimal(row["Price"].ToString())
                    };
                    itemsComplete.Add(item);
                }
                BasePage.ItemsCompleteGlobal = itemsComplete;
                DataTable OrderPlaces = _CN_Orders.CN_GetOrderPlaces();

                BasePage.PromocionGlobal = _CN_Orders.CN_GetPromocionbyPromoId();


                foreach (DataRow row in OrderPlaces.Rows)
                {
                    OrderPlace _OrderPlace = new OrderPlace
                    {
                        OrderPlaceId = Convert.ToInt32(row["OrderPlaceId"].ToString()),
                        Description  = row["Description"].ToString()
                    };
                    _OrderPlaceList.Add(_OrderPlace);
                }
                BasePage.OrderPlaceGlobal = _OrderPlaceList;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
    private void PlaceDiamonds(PlaceOrder rule = PlaceOrder.Random)
    {
        IPlaceable placeObject;

        if (rule == PlaceOrder.Oredered)
        {
            placeObject = new OrderPlace();
        }
        else
        {
            placeObject = new RandomPlace();
        }

        placeObject.Place(_diamondsPositions, _collectablePool, _lastIndex);

        _lastIndex++;
        _lastIndex = (_lastIndex >= _maxPlacesInStack) ? 0 : _lastIndex;

        _diamondsPositions = new List <Vector3>();
    }
Exemplo n.º 6
0
 public bool Put([FromBody] OrderPlace orderPlace)
 {
     _orderRepository.UpdateOrder(orderPlace);
     return(true);
 }
Exemplo n.º 7
0
 public bool Post([FromBody] OrderPlace orderPlace)
 {
     _orderRepository.AddOrder(orderPlace);
     return(true);
 }
Exemplo n.º 8
0
 public bool UpdateOrder(OrderPlace orderPlace)
 {
     _productContext.Entry(orderPlace).State = EntityState.Modified;
     _productContext.SaveChanges();
     return(true);
 }
Exemplo n.º 9
0
        public async Task <ServiceResult <PaymentCardResponse> > ProcessCardPaymentAsync(PaymentCardRequest request, int userId, OrderPlace orderPlace)
        {
            var authServiceResult = await _paymentAuthorizeService.GetAuthorizeTokenAsync();

            if (authServiceResult.IsValid)
            {
                using (var client = new HttpClient(new HttpClientHandler
                {
                    AllowAutoRedirect = false
                }))
                {
                    client.BaseAddress = new Uri(_paymentSettings.HostAddress);
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer",
                                                                                               authServiceResult.Result.access_token);

                    var orderPaymentInfo = await PrepareCompleteCardPayuRequestAsync(request);

                    var requestBody = JsonConvert.SerializeObject(request);

                    //var response = await client.PostAsync(_paymentSettings.OrderCreateEndpoint,
                    //            new StringContent(requestBody, Encoding.UTF8, "application/json"));

                    //if (response.IsSuccessStatusCode || response.StatusCode == HttpStatusCode.Found)
                    //{
                    //    var responseObj = JsonConvert.DeserializeObject<PaymentCardResponse>(await response.Content.ReadAsStringAsync());
                    //    await CreateNewOrderAsync(request, userId, orderPlace, orderPaymentInfo);
                    //    if (responseObj.status.statusCode == "SUCCESS")
                    //    {
                    //        return ServiceResult<PaymentCardResponse>.Success(responseObj);
                    //    }
                    //}
                    //return ServiceResult<PaymentCardResponse>.Failure(response.ReasonPhrase);


                    //TODO:Uncomment above code when payu express integrtation will work
                    await CreateNewOrderAsync(request, userId, orderPlace, orderPaymentInfo);

                    return(ServiceResult <PaymentCardResponse> .Success(new PaymentCardResponse
                    {
                        status = new CardStatus
                        {
                            statusCode = new Random().Next(0, 2) >= 1 ? "SUCCESS" : "ERROR",
                            statusDesc = "Request successful"
                        },
                        orderId = Guid.NewGuid().ToString(),
                        payMethods = new CardPayMethods
                        {
                            payMethod = new CardPayMethod
                            {
                                value = request.payMethods.payMethod.value,
                                card = new Card
                                {
                                    expirationMonth = "12",
                                    expirationYear = "2018",
                                    number = "12345*****2314"
                                }
                            }
                        }
                    }));
                }
            }
            return(ServiceResult <PaymentCardResponse> .Failure(authServiceResult.ValidationErrors));
        }
Exemplo n.º 10
0
        public async Task <ServiceResult <PaymentResponse> > ProcessPaymentAsync(PaymentRequest request, int userId, OrderPlace orderPlace)
        {
            var authServiceResult = await _paymentAuthorizeService.GetAuthorizeTokenAsync();

            if (authServiceResult.IsValid)
            {
                using (var client = new HttpClient(new HttpClientHandler
                {
                    AllowAutoRedirect = false
                }))
                {
                    client.BaseAddress = new Uri(_paymentSettings.HostAddress);
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer",
                                                                                               authServiceResult.Result.access_token);

                    var orderPaymentInfo = await PrepareCompletePayuRequestAsync(request);

                    var requestBody = JsonConvert.SerializeObject(request);

                    var response = await client.PostAsync(_paymentSettings.OrderCreateEndpoint,
                                                          new StringContent(requestBody, Encoding.UTF8, "application/json"));

                    if (response.IsSuccessStatusCode || response.StatusCode == HttpStatusCode.Found)
                    {
                        var responseObj = JsonConvert.DeserializeObject <PaymentResponse>(await response.Content.ReadAsStringAsync());
                        await CreateNewOrderAsync(request, userId, orderPlace, orderPaymentInfo);

                        if (responseObj.status.statusCode == "SUCCESS")
                        {
                            return(ServiceResult <PaymentResponse> .Success(responseObj));
                        }
                    }
                    return(ServiceResult <PaymentResponse> .Failure(response.ReasonPhrase));
                }
            }
            return(ServiceResult <PaymentResponse> .Failure(authServiceResult.ValidationErrors));
        }
Exemplo n.º 11
0
        private async Task CreateNewOrderAsync(PaymentCardRequest request, int userId, OrderPlace orderPlace, OrderPaymentInfo paymentInfo)
        {
            var order = new OrderBaseDto
            {
                UserId          = userId,
                Date            = DateTime.Now,
                ExtOrderId      = new Guid(request.extOrderId),
                NumOfCharges    = Convert.ToInt32(request.products[0].quantity),
                OrderPlace      = orderPlace,
                OrderState      = OrderStatus.Completed, //TODO: CHANGE TO PENDING WHEN PAYU EXPRESS INTEGRATION WILL WORK
                PricePerCharge  = paymentInfo.PricePerCharge,
                PriceTresholdId = paymentInfo.PriceTresholdId,
                Price           = paymentInfo.TotalAmount,
            };

            await _orderService.CreateAsync(order);
        }