public ActionResult Create()
        {
            var paypalapiList = this.ImsService.GetPaypalApiList(new PaypalApiRequest {
                IsActive = true
            });

            this.ViewBag.PaypalApiID = new SelectList(paypalapiList, "ID", "PPAccount");

            var productlist = this.ImsService.GetProductList();

            this.ViewBag.ProductID = new SelectList(productlist, "ID", "Sku");


            var query = from d in this.ImsService.DistinctPaymentItemInfo()
                        group new { d.Name, d.Number } by d.Number into ItemGp
            select ItemGp.FirstOrDefault();

            this.ViewBag.ItemNumber = new SelectList(query, "Number", "Name");


            this.ViewBag.SellingPlace = new SelectList(this.ImsService.GetCountryNameAndCode(), "ShipToCountryCode", "ShipToCountryName");
            this.ViewBag.StorePlace   = new SelectList(this.ImsService.GetCountryNameAndCode(), "ShipToCountryCode", "ShipToCountryName");
            var model = new Association();

            return(View("Edit", model));
        }
        public ActionResult Edit(int id)
        {
            var model = this.ImsService.GetAssociation(id);

            var paypalapiList = this.ImsService.GetPaypalApiList();

            this.ViewBag.PaypalApiID = new SelectList(paypalapiList, "ID", "PPAccount", model.PaypalApiID);

            var productlist = this.ImsService.GetProductList();

            this.ViewBag.ProductID = new SelectList(productlist, "ID", "Sku", model.ProductID);


            //var query = from d in this.ImsService.DistinctTransactionItem()
            //            group new { d.ItemTitle } by d.ItemTitle into ItemGp
            //            select ItemGp.FirstOrDefault();
            //this.ViewBag.ItemTitle = new SelectList(query, "ItemTitle", "ItemTitle", model.ItemTitle);
            var query = from d in this.ImsService.DistinctPaymentItemInfo()
                        group new { d.Name, d.Number } by d.Number into ItemGp
            select ItemGp.FirstOrDefault();

            this.ViewBag.ItemNumber = new SelectList(query, "Number", "Name", model.ItemNumber);

            this.ViewBag.SellingPlace = new SelectList(this.ImsService.GetCountryNameAndCode(), "ShipToCountryCode", "ShipToCountryName", model.SellingPlace);
            this.ViewBag.StorePlace   = new SelectList(this.ImsService.GetCountryNameAndCode(), "ShipToCountryCode", "ShipToCountryName", model.StorePlace);


            return(View(model));
        }
        public ActionResult Create()
        {
            var paypalapiList = this.ImsService.GetPaypalApiList();

            this.ViewBag.PaypalApiID = new SelectList(paypalapiList, "ID", "PPAccount");

            var productlist = this.ImsService.GetProductList();

            this.ViewBag.ProductID = new SelectList(productlist, "ID", "Sku");


            var query = from d in this.ImsService.DistinctTransactionItem()
                        group new { d.ItemTitle } by d.ItemTitle into ItemGp
            select ItemGp.FirstOrDefault();

            this.ViewBag.ItemTitle = new SelectList(query, "ItemTitle", "ItemTitle");


            this.ViewBag.SellingPlace = new SelectList(this.ImsService.GetCountryNameAndCode(), "ShipToCountryCode", "ShipToCountryName");
            this.ViewBag.StorePlace   = new SelectList(this.ImsService.GetCountryNameAndCode(), "ShipToCountryCode", "ShipToCountryName");
            var model = new Association();

            return(View("Edit", model));
        }
        public ActionResult Stats2()
        {
            string year = Request["year"] ?? "2014";
            //string daysaleinmonth = Request["daysaleinmonth"] ?? "2014";
            var transactions = this.ImsService.GetPaymentTransactionList(null);

            var calendar = from c in transactions
                           group new
            {
                start = DateTime.Parse(c.PaymentInfo.PaymentDate).ToCnDataString(),
                end   = DateTime.Parse(c.PaymentInfo.PaymentDate).ToCnDataString(),
            }
            by DateTime.Parse(c.PaymentInfo.PaymentDate).ToCnDataString()
            into ItemGp
            select new
            {
                start = ItemGp.Key,
                end   = ItemGp.Key,
                title = ItemGp.Count(),
                url   = "http://www.baidu.com"
            };

            var monthsale = from c in transactions
                            where
                            DateTime.Parse(c.PaymentInfo.PaymentDate).ToString("yyyy") == year &&
                            c.PaymentInfo.GrossAmount.currencyID == CurrencyCodeType.GBP
                            orderby c.PaymentInfo.PaymentDate ascending
                            group c by DateTime.Parse(c.PaymentInfo.PaymentDate).ToString("yyyy-MM")
                            into ItemGp
                            select new[]
            {
                DateTime.Parse(ItemGp.Key).ToString("MMM"),
                ItemGp.Sum(c => c.PaymentInfo.GrossAmount.value.ToDecimal()).ToString(),
            };
            var monthsaleamount = (from c in transactions
                                   where
                                   DateTime.Parse(c.PaymentInfo.PaymentDate).ToString("yyyy") == year &&
                                   c.PaymentInfo.GrossAmount.currencyID == CurrencyCodeType.GBP
                                   select c.PaymentInfo.GrossAmount.value.ToDecimal()
                                   ).Sum();
            var monthsaleqty = (from c in transactions
                                where
                                DateTime.Parse(c.PaymentInfo.PaymentDate).ToString("yyyy") == year &&
                                c.PaymentInfo.GrossAmount.currencyID == CurrencyCodeType.GBP
                                select c).Count();



            string daysaleinmonthend = Request["daysaleinmonth"] != null ? "2011-05-31" : "2011-05-08";

            var daysale = from c in transactions
                          where
                          DateTime.Parse(c.PaymentInfo.PaymentDate) >= DateTime.Parse("2011-05-01") &&
                          DateTime.Parse(c.PaymentInfo.PaymentDate) <= DateTime.Parse(daysaleinmonthend) &&
                          c.PaymentInfo.GrossAmount.currencyID == CurrencyCodeType.GBP
                          orderby c.PaymentInfo.PaymentDate ascending
                          group c by DateTime.Parse(c.PaymentInfo.PaymentDate).ToString("yyyy-MM-dd")
                          into ItemGp
                          select new[]
            {
                Request["daysaleinmonth"] != null?DateTime.Parse(ItemGp.Key).ToString("dd") : DateTime.Parse(ItemGp.Key).ToString("ddd(MMMd日)"),
                    ItemGp.Sum(c => c.PaymentInfo.GrossAmount.value.ToDecimal()).ToString(),
            };

            var totalamount = (from c in transactions
                               where c.PaymentInfo.GrossAmount.currencyID == CurrencyCodeType.GBP
                               select c.PaymentInfo.GrossAmount.value.ToDecimal()
                               ).Sum();

            var totalqty = (from c in transactions
                            where
                            c.PaymentInfo.GrossAmount.currencyID == CurrencyCodeType.GBP
                            select c).Count();

            //Func<Evisou.Core.Log.AuditLog, string> content2 = (c => c.ModuleName);


            //var auditloglist = this.ImsService.GetAuditLogList(null);
            //var auditlogs = (from c in auditloglist
            //                 where c.UserName == Evisou.Web.AdminApplication.Common.AdminUserContext.Current.LoginInfo.LoginName
            //                 orderby c.CreateTime descending
            //                 select new
            //                 {
            //                     createtime = c.CreateTime.ToRecentDay(),
            //                     content = //"用户:" + c.UserName + " " +
            //                     c.EventType + " " + "模块:"
            //                     + c.ModuleName + " " + "值为:"
            //                     + StringUtil.CutString(StringUtil.RemoveHtml(c.NewValues), 40),
            //                 }
            //                    ).Take(20);

            //var auditlogs = string.Empty;

            return(Json(new
            {
                data = new
                {
                    calresult = calendar,
                    monthsale = new
                    {
                        monthsaleresult = monthsale,
                        monthsaleamount = monthsaleamount,
                        monthsaleqty = monthsaleqty
                    },
                    daysale = new
                    {
                        daysaleresult = daysale
                    },
                    total = new
                    {
                        amount = totalamount,
                        qty = totalqty
                    },
                    //cpu = temp//HR.GetCpuInfo()
                    logs = new
                    {
                        auditlogs = new object()
                    }
                }
            },
                        JsonRequestBehavior.AllowGet));
        }