示例#1
0
        public async Task <HttpMessage <string> > OrderPay(QueryWithSettings qs)
        => await TryCatchResponseAsync(async() =>
        {
            return(await Task.Run(() =>
            {
                Principal principal = Core.Http.HttpContext.Current.User as Principal;
                int userId = principal == null || principal.User == null ? 0 : principal.User.Id;
                string result = "Ok";

                StatusInfo si = GetOrderStatus(qs.languageId, "Order.Header.Payed");

                if (si != null && si.Status != null && si.Status.Id > 0 && si.StatusType != null && si.StatusType.Id > 0)
                {
                    UpdateOrderStatus(qs.languageId, qs.orderId, si);
                    si = GetOrderStatus(qs.languageId, "Order.Item.Payed");
                    if (si != null && si.Status != null && si.Status.Id > 0 && si.StatusType != null && si.StatusType.Id > 0)
                    {
                        UpdateOrderItemStatus(qs.languageId, qs.orderId, si);
                    }
                }
                else
                {
                    result = "Невозможно обновить статус заказа";
                }



                return CreateResponseOk(result);
            }));
        });
示例#2
0
        public async Task <HttpMessage <BasketBillingAddressData> > BillingData(QueryWithSettings qs)
        => await TryCatchResponseAsync(async() =>
        {
            return(await Task.Run(() =>
            {
                BasketBillingAddressData result = new BasketBillingAddressData()
                {
                    Countries = new List <Country>()
                };

                //Lang lang = AccountController.GetLanguages(qs.languageId).FirstOrDefault();
                result.Countries = AccountController.GetCountries(qs.languageId);


                int billingId = GetBasketBilling(qs.uid);

                Principal principal = Core.Http.HttpContext.Current.User as Principal;
                int userId = principal == null || principal.User == null ? 0 : principal.User.Id;

                result.BillingAddress = GetAddressDefault(userId, billingId, qs, 4);
                if (result.BillingAddress == null)
                {
                    billingId = GetBasketDelivery(qs.uid);
                    result.BillingAddress = GetAddressDefault(userId, billingId, qs, 3);
                }

                return CreateResponseOk(result);
            }));
        });
示例#3
0
        public async Task <HttpMessage <List <Order> > > Orders(QueryWithSettings qs)
        => await TryCatchResponseAsync(async() =>
        {
            return(await Task.Run(() =>
            {
                Principal principal = Core.Http.HttpContext.Current.User as Principal;
                int userId = principal == null || principal.User == null ? 0 : principal.User.Id;
                List <Order> orders = GetOrders(userId, 0, qs);

                StatusInfo si = null;
                foreach (var o in orders)
                {
                    if (o.Status == null || o.Status.Id < 1)
                    {
                        if (si == null)
                        {
                            si = GetOrderStatus(qs.languageId, "Order.Header.New");
                        }
                        o.Status = si.Status;
                        o.StatusType = si.StatusType;
                    }
                }
                return CreateResponseOk(orders);
            }));
        });
示例#4
0
        public async Task <HttpMessage <OrderInfo> > OrderInfo(QueryWithSettings qs)
        => await TryCatchResponseAsync(async() =>
        {
            return(await Task.Run(() =>
            {
                Principal principal = Core.Http.HttpContext.Current.User as Principal;
                int userId = principal == null || principal.User == null ? 0 : principal.User.Id;
                List <Order> orders = GetOrders(userId, qs.orderId, qs);

                OrderInfo result = new OrderInfo();
                result.Order = orders != null && orders.Count > 0 ? orders[0]: new Order();
                if (result.Order.Status == null || result.Order.Status.Id < 1)
                {
                    StatusInfo si = GetOrderStatus(qs.languageId, "Order.Header.New");
                    result.Order.Status = si.Status;
                    result.Order.StatusType = si.StatusType;
                }

                result.Items = OrderItems(qs.orderId, qs);

                List <AddressInfo> addr = GetAddress(qs.orderId, qs, 3);
                result.BillingAddress = addr != null && addr.Count > 0 ? addr[0] : new AddressInfo();
                addr = GetAddress(qs.orderId, qs, 4);
                result.DeliveryAddress = addr != null && addr.Count > 0 ? addr[0] : new AddressInfo();

                return CreateResponseOk(result);
            }));
        });
 public async Task <HttpMessage <List <AskQuestion> > > AskQuestionInfo(QueryWithSettings q)
 => await TryCatchResponseAsync(async() =>
 {
     return(await Task.Run(() =>
     {
         Principal principal = Core.Http.HttpContext.Current.User as Principal;
         int userId = principal == null || principal.User == null ? 0 : principal.User.Id;
         List <AskQuestion> result = GetAskQuestionInfo(userId == 0 ? -1 : q.askQuestionId, userId);
         return CreateResponseOk(result);
     }));
 });
示例#6
0
        public async Task <HttpMessage <List <AddressInfo> > > Addresses(QueryWithSettings qs)
        => await TryCatchResponseAsync(async() =>
        {
            return(await Task.Run(() =>
            {
                Principal principal = Core.Http.HttpContext.Current.User as Principal;
                string email = principal == null || principal.User == null ? string.Empty : principal.User.Email;
                int userId = principal == null || principal.User == null ? 0 : principal.User.Id;

                List <AddressInfo> addresses = GetAddresses(userId, qs, -1, -1);
                List <AddressInfo> result = (addresses.Count > 0 ? addresses.Where(f => f.UserId == userId).ToList() : addresses);
                return CreateResponseOk(result);
            }));
        });
示例#7
0
 public async Task <HttpMessage <OrderCreateResult> > OrderCreate(QueryWithSettings qs)
 => await TryCatchResponseAsync(async() =>
 {
     return(await Task.Run(() =>
     {
         //string result = "Ok";
         Principal principal = Core.Http.HttpContext.Current.User as Principal;
         int userId = principal == null || principal.User == null ? 0 : principal.User.Id;
         OrderCreateResult result = OrderCreateSql(userId, qs);
         if (result.OrderHeaderID > 0 && result.OrderNumber > 0)
         {
             ClearBasket(qs);
         }
         return CreateResponseOk(result);
     }));
 });
示例#8
0
 public async Task <HttpMessage <List <Payment> > > PaymentList(QueryWithSettings qs)
 => await TryCatchResponseAsync(async() =>
 {
     return(await Task.Run(() =>
     {
         List <Payment> result = GetPaymentList(qs);
         foreach (Payment p in result)
         {
             if (p.Code.ToUpper() == "CARD")
             {
                 p.Logo = "/img/payments/flat/default.svg";
             }
             else if (p.Code.ToUpper() == "PAYPAL")
             {
                 p.Logo = "/img/payments/flat/paypal.svg";
             }
         }
         return CreateResponseOk(result);
     }));
 });
示例#9
0
        internal static List <AddressInfo> GetAddresses(int userId, QueryWithSettings qs, int typeAddress = -1, int countryId = -1)
        {
            List <AddressInfo> result = new List <AddressInfo>();

            int f_Id = -1, f_FullName = -1;
            int f_CompanyId = -1, f_CompanyCode = -1, f_CompanyName = -1;
            int f_CountryId = -1, f_CountryCode = -1, f_CountryName = -1;
            int f_ZipCode = -1, f_Region = -1, f_City = -1, f_Address = -1;
            int f_PhoneCode = -1, f_PhoneMain = -1, f_PhoneExt = -1, f_Email = -1;
            int f_Default = -1, f_AddressTypeId = -1, f_UserId = -1;

            AppSettings.Query.GlobalParts.Execute(@"Account\[get_address]"
                                                  , new SqlParameter[]
            {
                new SqlParameter()
                {
                    ParameterName = "@AddressTypeID", Value = typeAddress
                },
                new SqlParameter()
                {
                    ParameterName = "@SiteUserID", Value = userId
                },
                new SqlParameter()
                {
                    ParameterName = "@LocaleLanguageID", Value = qs.languageId
                },
                new SqlParameter()
                {
                    ParameterName = "@CountryID", Value = countryId
                }
            }
                                                  , onExecute: (reader) =>
            {
                string fname;
                for (int i = 0, icount = reader.FieldCount; i < icount; i++)
                {
                    fname = reader.GetName(i);
                    if (fname == "AddressID")
                    {
                        f_Id = i;
                    }
                    else if (fname == "FullName")
                    {
                        f_FullName = i;
                    }

                    else if (fname == "CompanyID")
                    {
                        f_CompanyId = i;
                    }
                    else if (fname == "ComapnyCode")
                    {
                        f_CompanyCode = i;
                    }
                    else if (fname == "ComapnyDescr")
                    {
                        f_CompanyName = i;
                    }

                    else if (fname == "CountryID")
                    {
                        f_CountryId = i;
                    }
                    else if (fname == "CountryCode")
                    {
                        f_CountryCode = i;
                    }
                    else if (fname == "CountryDescr")
                    {
                        f_CountryName = i;
                    }

                    else if (fname == "ZipCode")
                    {
                        f_ZipCode = i;
                    }
                    else if (fname == "Region")
                    {
                        f_Region = i;
                    }
                    else if (fname == "City")
                    {
                        f_City = i;
                    }
                    else if (fname == "Address")
                    {
                        f_Address = i;
                    }

                    else if (fname == "PhoneCode")
                    {
                        f_PhoneCode = i;
                    }
                    else if (fname == "PhoneMain")
                    {
                        f_PhoneMain = i;
                    }
                    else if (fname == "PhoneExt")
                    {
                        f_PhoneExt = i;
                    }
                    else if (fname == "Email")
                    {
                        f_Email = i;
                    }

                    else if (fname == "IsDefault")
                    {
                        f_Default = i;
                    }
                    else if (fname == "AddressType")
                    {
                        f_AddressTypeId = i;
                    }
                    else if (fname == "UserID")
                    {
                        f_UserId = i;
                    }
                }
            }
                                                  , (values) =>
            {
                AddressInfo item = new AddressInfo()
                {
                    Company = new Company(), Country = new Country()
                };

                if (f_Id > -1)
                {
                    item.Id = values[f_Id].ToInt();
                }
                if (f_FullName > -1)
                {
                    item.FullName = values[f_FullName].ToStr();
                }

                if (f_CompanyId > -1)
                {
                    item.CompanyId = item.Company.Id = values[f_CompanyId].ToInt();
                }
                if (f_CompanyCode > -1)
                {
                    item.Company.Code = values[f_CompanyCode].ToStr();
                }
                if (f_CompanyName > -1)
                {
                    item.Company.Name = values[f_CompanyName].ToStr();
                }

                if (f_CountryId > -1)
                {
                    item.CountryId = item.Country.Id = values[f_CountryId].ToInt();
                }
                if (f_CountryCode > -1)
                {
                    item.Country.Code = values[f_CountryCode].ToStr();
                }
                if (f_CountryName > -1)
                {
                    item.Country.Name = values[f_CountryName].ToStr();
                }

                if (f_ZipCode > -1)
                {
                    item.ZipCode = values[f_ZipCode].ToStr();
                }
                if (f_Region > -1)
                {
                    item.Region = values[f_Region].ToStr();
                }
                if (f_City > -1)
                {
                    item.City = values[f_City].ToStr();
                }
                if (f_Address > -1)
                {
                    item.Street = values[f_Address].ToStr();
                }

                if (f_PhoneCode > -1)
                {
                    item.PhoneCode = values[f_PhoneCode].ToStr();
                }
                if (f_PhoneMain > -1)
                {
                    item.Phone = values[f_PhoneMain].ToStr();
                }
                if (f_PhoneExt > -1)
                {
                    item.PhoneExt = values[f_PhoneExt].ToStr();
                }
                if (f_Email > -1)
                {
                    item.Email = values[f_Email].ToStr();
                }

                if (f_Default > -1)
                {
                    item.Default = values[f_Default].ToBool();
                }
                if (f_AddressTypeId > -1)
                {
                    item.AddressTypeId = values[f_AddressTypeId].ToDecimal();
                }
                if (f_UserId > -1)
                {
                    item.UserId = values[f_UserId].ToInt();
                }
                result.Add(item);
            });

            return(result);
        }
示例#10
0
        private List <OrderInfoItem> OrderItems(int orderId, QueryWithSettings qs)
        {
            List <OrderInfoItem> result = new List <OrderInfoItem>();
            int f_OrderItemID = -1, f_Id = -1, f_Articul = -1, f_PartNumber = -1, f_Name = -1, f_BrandCode = -1;
            int f_Qty = -1, f_CartPrice = -1, f_CartAmount = -1, f_CartDeliveryAmount = -1, f_CartVatAmount = -1, f_CartVatTotalAmount = -1;

            int f_StatusID = -1, f_StatusCode = -1, f_StatusDescr = -1;
            int f_StatusTypeID = -1, f_StatusTypeCode = -1, f_StatusTypeDescr = -1;

            AppSettings.Query.GlobalParts.Execute(@"Account\[r_OrderItemGet]", new SqlParameter[]
            {
                new SqlParameter()
                {
                    ParameterName = "@LocaleLanguageID", Value = qs.languageId
                },
                new SqlParameter()
                {
                    ParameterName = "@OrderHeaderID", Value = orderId
                },
            }
                                                  , onExecute: (reader) =>
            {
                string fname;
                for (int i = 0, icount = reader.FieldCount; i < icount; i++)
                {
                    fname = reader.GetName(i);
                    if (fname == "OrderItemID")
                    {
                        f_OrderItemID = i;
                    }
                    else if (fname == "GoodsID")
                    {
                        f_Id = i;
                    }
                    else if (fname == "Articul")
                    {
                        f_Articul = i; f_PartNumber = i;
                    }
                    else if (fname == "Descr")
                    {
                        f_Name = i;
                    }
                    else if (fname == "Brand")
                    {
                        f_BrandCode = i;
                    }
                    else if (fname == "Qty")
                    {
                        f_Qty = i;
                    }

                    else if (fname == "CartPrice")
                    {
                        f_CartPrice = i;
                    }
                    else if (fname == "CartAmount")
                    {
                        f_CartAmount = i;
                    }
                    else if (fname == "CartDeliveryAmount")
                    {
                        f_CartDeliveryAmount = i;
                    }
                    else if (fname == "CartVatAmount")
                    {
                        f_CartVatAmount = i;
                    }
                    else if (fname == "CartVatTotalAmount")
                    {
                        f_CartVatTotalAmount = i;
                    }

                    else if (fname == "StatusID")
                    {
                        f_StatusID = i;
                    }
                    else if (fname == "StatusCode")
                    {
                        f_StatusCode = i;
                    }
                    else if (fname == "StatusDescr")
                    {
                        f_StatusDescr = i;
                    }

                    else if (fname == "StatusTypeID")
                    {
                        f_StatusTypeID = i;
                    }
                    else if (fname == "StatusTypeCode")
                    {
                        f_StatusTypeCode = i;
                    }
                    else if (fname == "StatusTypeDescr")
                    {
                        f_StatusTypeDescr = i;
                    }
                }
            }
                                                  , (values) =>
            {
                int id = 0;
                if (f_OrderItemID > -1)
                {
                    id = values[f_OrderItemID].ToInt();
                }
                else
                {
                    return;
                }


                OrderInfoItem item = new OrderInfoItem()
                {
                    OrderItemID = id, Brand = new Brand(), Status = new Status(), StatusType = new StatusType()
                };
                result.Add(item);

                if (f_Id > -1)
                {
                    item.Id = values[f_Id].ToInt();
                }
                if (f_PartNumber > -1)
                {
                    item.PartNumber = values[f_PartNumber].ToStr();
                }
                if (f_Name > -1)
                {
                    item.Name = values[f_Name].ToStr();
                }
                if (f_Articul > -1)
                {
                    item.Articul = values[f_Articul].ToStr();
                }
                if (f_BrandCode > -1)
                {
                    item.Brand.Code = values[f_BrandCode].ToStr();
                }

                if (f_Qty > -1)
                {
                    item.Qty = values[f_Qty].ToDecimal();
                }
                if (f_CartPrice > -1)
                {
                    item.Price = values[f_CartPrice].ToDecimal();
                }

                if (f_CartAmount > -1)
                {
                    item.Amount = values[f_CartAmount].ToDecimal();
                }
                if (f_CartDeliveryAmount > -1)
                {
                    item.DeliveryAmount = values[f_CartDeliveryAmount].ToDecimal();
                }
                if (f_CartVatAmount > -1)
                {
                    item.VatAmount = values[f_CartVatAmount].ToDecimal();
                }
                if (f_CartVatTotalAmount > -1)
                {
                    item.TotalAmount = values[f_CartVatTotalAmount].ToDecimal();
                }

                if (f_StatusID > -1)
                {
                    item.Status.Id = values[f_StatusID].ToInt();
                }
                if (f_StatusCode > -1)
                {
                    item.Status.Code = values[f_StatusCode].ToStr();
                }
                if (f_StatusDescr > -1)
                {
                    item.Status.Name = values[f_StatusDescr].ToStr();
                }

                if (f_StatusTypeID > -1)
                {
                    item.StatusType.Id = values[f_StatusTypeID].ToInt();
                }
                if (f_StatusTypeCode > -1)
                {
                    item.StatusType.Code = values[f_StatusTypeCode].ToStr();
                }
                if (f_StatusTypeDescr > -1)
                {
                    item.StatusType.Name = values[f_StatusTypeDescr].ToStr();
                }
            });

            return(result);
        }
示例#11
0
        internal static List <Order> GetOrders(int userId, int orderId, QueryWithSettings qs)
        {
            List <Order> result = new List <Order>();

            int f_OrderHeaderID = -1, f_OrderNumberFull = -1, f_OrderDate = -1, f_Comment = -1;
            int f_OrderCurrencyID = -1, f_OrderCurrencyCode = -1;
            int f_DeliveryTariffID = -1, f_DeliveryTariffDescr = -1;

            int f_StatusID = -1, f_StatusCode = -1, f_StatusDescr = -1;
            int f_StatusTypeID = -1, f_StatusTypeCode = -1, f_StatusTypeDescr = -1;

            AppSettings.Query.GlobalParts.Execute(@"Account\[r_OrderGet]"
                                                  , sqlParameters: new SqlParameter[]
            {
                new SqlParameter("@LocaleLanguageID", qs.languageId),
                new SqlParameter("@SiteUserID", userId),
                new SqlParameter("@OrderHeaderID", orderId)
            }
                                                  , onExecute: (reader) =>
            {
                string fname;
                for (int i = 0, icount = reader.FieldCount; i < icount; i++)
                {
                    fname = reader.GetName(i);
                    if (fname == "OrderHeaderID")
                    {
                        f_OrderHeaderID = i;
                    }
                    else if (fname == "OrderNumberFull")
                    {
                        f_OrderNumberFull = i;
                    }
                    else if (fname == "OrderDate")
                    {
                        f_OrderDate = i;
                    }
                    else if (fname == "Comment")
                    {
                        f_Comment = i;
                    }

                    else if (fname == "OrderCurrencyID")
                    {
                        f_OrderCurrencyID = i;
                    }
                    else if (fname == "OrderCurrencyCode")
                    {
                        f_OrderCurrencyCode = i;
                    }

                    else if (fname == "DeliveryTariffID")
                    {
                        f_DeliveryTariffID = i;
                    }
                    else if (fname == "DeliveryTariffDescr")
                    {
                        f_DeliveryTariffDescr = i;
                    }

                    else if (fname == "StatusID")
                    {
                        f_StatusID = i;
                    }
                    else if (fname == "StatusCode")
                    {
                        f_StatusCode = i;
                    }
                    else if (fname == "StatusDescr")
                    {
                        f_StatusDescr = i;
                    }

                    else if (fname == "StatusTypeID")
                    {
                        f_StatusTypeID = i;
                    }
                    else if (fname == "StatusTypeCode")
                    {
                        f_StatusTypeCode = i;
                    }
                    else if (fname == "StatusTypeDescr")
                    {
                        f_StatusTypeDescr = i;
                    }
                }
            }
                                                  , action: (values) =>
            {
                Order order = new Order()
                {
                    Currency = new Currency(), Delivery = new DeliveryInfo(), Status = new Status(), StatusType = new StatusType()
                };
                if (f_OrderHeaderID > -1)
                {
                    order.OrderHeaderID = values[f_OrderHeaderID].ToInt();
                }
                if (f_OrderNumberFull > -1)
                {
                    order.OrderNumberFull = values[f_OrderNumberFull].ToStr();
                }
                if (f_OrderDate > -1)
                {
                    order.OrderDate = values[f_OrderDate].ToDateTime();
                }
                if (f_Comment > -1)
                {
                    order.Comment = values[f_Comment].ToStr();
                }
                if (f_OrderCurrencyID > -1)
                {
                    order.Currency.Id = values[f_OrderCurrencyID].ToInt();
                }
                if (f_OrderCurrencyCode > -1)
                {
                    order.Currency.Code = values[f_OrderCurrencyCode].ToStr();
                }
                if (f_DeliveryTariffID > -1)
                {
                    order.Delivery.Id = values[f_DeliveryTariffID].ToInt();
                }
                if (f_DeliveryTariffDescr > -1)
                {
                    order.Delivery.Name = values[f_DeliveryTariffDescr].ToStr();
                }

                if (f_StatusID > -1)
                {
                    order.Status.Id = values[f_StatusID].ToInt();
                }
                if (f_StatusCode > -1)
                {
                    order.Status.Code = values[f_StatusCode].ToStr();
                }
                if (f_StatusDescr > -1)
                {
                    order.Status.Name = values[f_StatusDescr].ToStr();
                }

                if (f_StatusTypeID > -1)
                {
                    order.StatusType.Id = values[f_StatusTypeID].ToInt();
                }
                if (f_StatusTypeCode > -1)
                {
                    order.StatusType.Code = values[f_StatusTypeCode].ToStr();
                }
                if (f_StatusTypeDescr > -1)
                {
                    order.StatusType.Name = values[f_StatusTypeDescr].ToStr();
                }

                result.Add(order);
            });
            return(result);
        }