public ActionResult Edit(EbayType obj)
 {
     try
     {
         NSession.Update(obj);
         NSession.Flush();
     }
     catch (Exception ee)
     {
         return(Json(new { ErrorMsg = "出错了", IsSuccess = false }));
     }
     return(Json(new { IsSuccess = "true" }));
 }
        /// <summary>
        /// 根据Id获取
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public EbayType GetById(int Id)
        {
            EbayType obj = NSession.Get <EbayType>(Id);

            if (obj == null)
            {
                throw new Exception("返回实体为空");
            }
            else
            {
                return(obj);
            }
        }
 public string SetStock(EbayType obj)
 {
     try
     {
         NSession.Save(obj);
         NSession.Flush();
         return("保存成功");
     }
     catch (Exception e)
     {
         return("保存出错");
     }
 }
 public JsonResult DeleteConfirmed(int id)
 {
     try
     {
         EbayType obj = GetById(id);
         NSession.Delete(obj);
         NSession.Flush();
     }
     catch (Exception ee)
     {
         return(Json(new { ErrorMsg = "出错了", IsSuccess = false }));
     }
     return(Json(new { IsSuccess = "true" }));
 }
        public ActionResult Edit(int id)
        {
            EbayType obj = GetById(id);

            return(View(obj));
        }
        public static void GetMyeBaySelling(AccountType sa, ISession NSession)
        {
            if (sa == null)
            {
                return;
            }
            ApiContext context = EBayUtil.GetGenericApiContext("US");

            context.ApiCredential.eBayToken = sa.ApiToken;
            GetMyeBaySellingCall apicall = new GetMyeBaySellingCall(context);

            apicall.ActiveList = new ItemListCustomizationType();
            int i = 1;

            DeleteALL(sa.AccountName, NSession);

            do
            {
                apicall.ActiveList.Pagination = new PaginationType();
                apicall.ActiveList.Pagination.EntriesPerPage = 200;
                apicall.ActiveList.Pagination.PageNumber     = i;
                apicall.GetMyeBaySelling();

                if (apicall.ActiveListReturn != null && apicall.ActiveListReturn.ItemArray != null && apicall.ActiveListReturn.ItemArray.Count > 0)
                {
                    foreach (ItemType actitem in apicall.ActiveListReturn.ItemArray)
                    {
                        try
                        {
                            if (actitem.SellingStatus != null)
                            {
                                EbayType ei = new EbayType();
                                ei.ItemId = actitem.ItemID;


                                ei.ItemTitle = actitem.Title;
                                ei.Price     = actitem.SellingStatus.CurrentPrice.Value.ToString();


                                ei.Currency   = actitem.SellingStatus.CurrentPrice.currencyID.ToString();
                                ei.StartNum   = actitem.Quantity;
                                ei.NowNum     = actitem.QuantityAvailable;
                                ei.ProductUrl = actitem.ListingDetails.ViewItemURL;
                                if (actitem.PictureDetails != null && actitem.PictureDetails.GalleryURL != null)
                                {
                                    ei.PicUrl = actitem.PictureDetails.GalleryURL;
                                }
                                ei.StartTime = actitem.ListingDetails.StartTime;
                                ei.Account   = sa.AccountName;
                                ei.Status    = "销售中";
                                ei.SKU       = "";
                                if (actitem.SKU != null)
                                {
                                    ei.SKU = actitem.SKU;
                                    if (ei.NowNum == 0)
                                    {
                                        ei.Status = "卖完";
                                    }
                                    NSession.Clear();
                                    ei.CreateOn = DateTime.Now;
                                    NSession.Save(ei);
                                    NSession.Flush();
                                }
                                else
                                {
                                    if (actitem.Variations != null)
                                    {
                                        foreach (VariationType v in actitem.Variations.Variation)
                                        {
                                            NSession.Clear();
                                            ei.SKU      = v.SKU;
                                            ei.StartNum = v.Quantity;
                                            ei.NowNum   = v.Quantity - v.SellingStatus.QuantitySold;
                                            ei.Status   = "销售中";
                                            if (ei.NowNum == 0)
                                            {
                                                ei.Status = "卖完";
                                            }
                                            ei.ItemTitle = v.VariationTitle;

                                            ei.CreateOn = DateTime.Now;
                                            NSession.Save(ei);
                                            NSession.Flush();
                                        }
                                    }
                                    else
                                    {
                                        ei.SKU = "";
                                        if (ei.NowNum == 0)
                                        {
                                            ei.Status = "卖完";
                                        }
                                        NSession.Clear();
                                        ei.CreateOn = DateTime.Now;
                                        NSession.Save(ei);
                                        NSession.Flush();
                                    }
                                }
                            }
                        }
                        catch (Exception)
                        {
                            continue;
                        }
                    }
                    i++;
                    if (i > apicall.ActiveListReturn.PaginationResult.TotalNumberOfPages)
                    {
                        break;
                    }
                }
            } while (apicall.ActiveListReturn != null && apicall.ActiveListReturn.ItemArray != null && apicall.ActiveListReturn.ItemArray.Count == 200);
        }