Exemplo n.º 1
0
        public List <object> GetUserAutosNumberGroupedByStatus(User user)
        {
            List <object> result = new List <object>();

            if (user != null)
            {
                var autos = AutoService.GetAll().Where(a => a.UserID == user.ID && a.StatusID != 4)
                            .GroupBy(item => new
                {
                    StatusID = item.StatusID
                })
                            .Select(item => new
                {
                    StatusID    = item.Key.StatusID,
                    AutosNumber = item.Count()
                })
                            .OrderBy(item => item.StatusID);

                foreach (var item in autos)
                {
                    result.Add(item);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public int GetAutosCountAddedToday()
        {
            DateTime todayStart = DateTime.Now.Date;
            DateTime todayEnd   = DateTime.Now.AddDays(1).Date;

            return(AutoService.GetAllPublished()
                   .Where(a => a.StatusID == 2 &&
                          a.DateAppearance != null &&
                          a.DateAppearance.Value >= todayStart &&
                          a.DateAppearance.Value < todayEnd)
                   .Count());
        }
Exemplo n.º 3
0
        public List <object> GetNumberOfAutosGroupedByMake()
        {
            List <object> result = new List <object>();
            var           autos  = AutoService.GetAllPublished()
                                   .GroupBy(item => new
            {
                MakeID = item.MakeID
            })
                                   .Select(item => new
            {
                MakeID      = item.Key.MakeID,
                MakeName    = item.Max(t => t.AutoMake.Name),
                AutosNumber = item.Count()
            })
                                   .OrderBy(item => item.MakeName);

            foreach (var item in autos)
            {
                result.Add(item);
            }

            return(result);
        }
Exemplo n.º 4
0
        public void Process(dynamic orderVM)
        {
            try
            {
                if (orderVM.LMI_HASH != Hash.GetHash(orderVM.LMI_MERCHANT_ID + orderVM.LMI_PAYMENT_NO + orderVM.LMI_PAYMENT_AMOUNT.ToString().Replace(',', '.') + XCarsConfiguration.LMI_secretKey))
                {
                    return;
                }

                string guid  = GetDynamicProperty(orderVM, "LMI_PAYMENT_NO");
                Order  order = GetByGUID(guid);
                if (order == null)
                {
                    return;
                }

                order.IsOpen        = false;
                order.User.Balance -= order.UsedFromBalance;

                //оплата за публикацию авто
                if (order.PurchaseTypeID == 1)
                {
                    int         top       = 0;
                    OrderDetail detailTop = order.OrderDetails.FirstOrDefault(d => d.Name == "top");
                    if (detailTop != null)
                    {
                        int.TryParse(detailTop.Value, out top);
                    }

                    int         days       = 0;
                    OrderDetail detailDays = order.OrderDetails.FirstOrDefault(d => d.Name == "days");
                    if (detailDays != null)
                    {
                        int.TryParse(detailDays.Value, out days);
                    }

                    try
                    {
                        int autoID = 0;
                        if (order.ObjectID != null)
                        {
                            autoID = (int)order.ObjectID;
                        }
                        Auto auto = AutoService.GetByID(autoID);
                        if (auto == null)
                        {
                            return;
                        }

                        DateTime dateExpires = DateTime.Now.AddDays(days);
                        AutoService.Publish(auto, dateExpires);
                        auto.CompletionJobID = HangfireService.CreateJobForAuto(auto);
                        auto.Top             = top;
                        AutoService.Edit(auto);
                    }
                    catch (Exception ex)
                    {
                    }
                }
                else if (order.PurchaseTypeID == 2)
                {
                    //........
                }

                Edit(order);

                int LMI_SYS_PAYMENT_ID = 0;
                int.TryParse(GetDynamicProperty(orderVM, "LMI_SYS_PAYMENT_ID"), out LMI_SYS_PAYMENT_ID);

                //create transaction
                Transaction transaction = new Transaction()
                {
                    Amount               = order.LMI_PAYMENT_AMOUNT,
                    DateCreated          = DateTime.Now,
                    ObjectID             = order.ObjectID,
                    PurchaseTypeID       = order.PurchaseTypeID,
                    StateID              = 1,
                    UserID               = order.UserID,
                    LMI_PAYMENT_SYSTEM   = GetDynamicProperty(orderVM, "LMI_PAYMENT_SYSTEM"),
                    LMI_SYS_PAYMENT_ID   = LMI_SYS_PAYMENT_ID,
                    LMI_PAYER_IDENTIFIER = GetDynamicProperty(orderVM, "LMI_PAYER_IDENTIFIER") ?? "unknown",
                    LMI_MODE             = order.LMI_MODE
                };

                DateTime dtTmp;
                if (DateTime.TryParse(GetDynamicProperty(orderVM, "LMI_SYS_PAYMENT_DATE"), out dtTmp))
                {
                    //if (DateTime.TryParse("2018-01-16 20:56:00", out dtTmp))
                    transaction.LMI_SYS_PAYMENT_DATE = dtTmp;
                }

                TransactionService.Create(transaction);
            }
            catch (Exception ex)
            {
            }
        }