示例#1
0
        public ActionResult AddDeal(CoinDealHistory coinDealHistory, 
            HttpPostedFileBase imageFile1,
            HttpPostedFileBase imageFile2,
            HttpPostedFileBase imageFile3,
            HttpPostedFileBase imageFile4,
            string rate)
        {
            if (!String.IsNullOrEmpty(rate))
            {
                HttpCookie myCookie = new HttpCookie("FYCoins");
                myCookie["RateUSD"] = rate;
                myCookie["DealDate"] = coinDealHistory.DealDate.ToString("yyyy-MM-dd");
                myCookie["DealCompany"] = coinDealHistory.DealCompany;
                myCookie.Expires = DateTime.Now.AddDays(365d);
                Response.Cookies.Add(myCookie);
            }

            coinDealHistory.Image1 = saveDealImage(imageFile1);
            coinDealHistory.Image2 = saveDealImage(imageFile2);
            coinDealHistory.Image3 = saveDealImage(imageFile3);
            coinDealHistory.Image4 = saveDealImage(imageFile4);

            CoinManager.CreateCoinDealHistory(coinDealHistory);

            return RedirectToAction("Details", new { id = coinDealHistory.CoinId });
        }
示例#2
0
        internal static int ModifyCoinHistory(CoinDealHistory coinDealHistory)
        {
            using (Entities ctx = new Entities())
            {
                var coinHistory = ctx.CoinDealHistories.SingleOrDefault(x => x.Id == coinDealHistory.Id);

                if (coinDealHistory != null)
                {
                    coinHistory.DealCompany = coinDealHistory.DealCompany;
                    coinHistory.DealDate = coinDealHistory.DealDate;
                    coinHistory.DealPrice = coinDealHistory.DealPrice;
                    coinHistory.DealPriceUSD = coinDealHistory.DealPriceUSD;
                    coinHistory.Description = coinDealHistory.Description;
                    coinHistory.Lot = coinDealHistory.Lot;
                    coinHistory.ModifyDate = DateTime.Now;
                    if (coinDealHistory.Image1 != String.Empty)
                        coinHistory.Image1 = coinDealHistory.Image1;
                    if (coinDealHistory.Image2 != String.Empty)
                        coinHistory.Image2 = coinDealHistory.Image2;
                    if (coinDealHistory.Image3 != String.Empty)
                        coinHistory.Image3 = coinDealHistory.Image3;
                    if (coinDealHistory.Image4 != String.Empty)
                        coinHistory.Image4 = coinDealHistory.Image4;
                }

                var coinRealtime = ctx.CoinDealRealtimes.SingleOrDefault(x => x.Id == coinDealHistory.Id);
                if (coinRealtime != null)
                {
                    coinRealtime.DealCompany = coinDealHistory.DealCompany;
                    coinRealtime.DealDate = coinDealHistory.DealDate;
                    coinRealtime.DealPrice = coinDealHistory.DealPrice;
                    coinRealtime.DealPriceUSD = coinDealHistory.DealPriceUSD;
                    coinRealtime.Description = coinDealHistory.Description;
                    coinRealtime.Lot = coinDealHistory.Lot;
                    coinRealtime.ModifyDate = DateTime.Now;
                    if (coinDealHistory.Image1 != String.Empty)
                        coinRealtime.Image1 = coinDealHistory.Image1;
                    if (coinDealHistory.Image2 != String.Empty)
                        coinRealtime.Image2 = coinDealHistory.Image2;
                    if (coinDealHistory.Image3 != String.Empty)
                        coinRealtime.Image3 = coinDealHistory.Image3;
                    if (coinDealHistory.Image4 != String.Empty)
                        coinRealtime.Image4 = coinDealHistory.Image4;
                }

                return ctx.SaveChanges();
            }
        }
示例#3
0
        internal static Guid CreateCoinDealHistory(CoinDealHistory coinDealHistory)
        {
            coinDealHistory.Id =
                coinDealHistory.Id == null || coinDealHistory.Id == Guid.Empty ?
                Guid.NewGuid() : coinDealHistory.Id;
            coinDealHistory.CreateDate = coinDealHistory.ModifyDate = DateTime.Now;

            using (Entities ctx = new Entities())
            {
                ctx.CoinDealHistories.AddObject(coinDealHistory);
                // 删除历史的拍卖纪录,保存表中只保留最新的一条拍卖纪录
                ctx.CoinDealRealtimes.Where(w => w.CoinId == coinDealHistory.CoinId)
                    .ToList().ForEach(ctx.CoinDealRealtimes.DeleteObject);
                // 创建新的拍卖实时记录
                CoinDealRealtime coinDealRealtime = new CoinDealRealtime();
                coinDealRealtime.Id = coinDealHistory.Id;
                coinDealRealtime.Image1 = coinDealHistory.Image1;
                coinDealRealtime.Image2 = coinDealHistory.Image2;
                coinDealRealtime.Image3 = coinDealHistory.Image3;
                coinDealRealtime.Image4 = coinDealHistory.Image4;
                coinDealRealtime.ModifyDate = coinDealHistory.ModifyDate;
                coinDealRealtime.CoinId = coinDealHistory.CoinId;
                coinDealRealtime.CreateDate = coinDealHistory.CreateDate;
                coinDealRealtime.DealCompany = coinDealHistory.DealCompany;
                coinDealRealtime.DealDate = coinDealHistory.DealDate;
                coinDealRealtime.DealPrice = coinDealHistory.DealPrice;
                coinDealRealtime.DealPriceUSD = coinDealHistory.DealPriceUSD;
                coinDealRealtime.Description = coinDealHistory.Description;
                coinDealRealtime.Lot = coinDealHistory.Lot;

                ctx.CoinDealRealtimes.AddObject(coinDealRealtime);

                ctx.SaveChanges();
            }

            return coinDealHistory.Id;
        }
示例#4
0
 /// <summary>
 /// Create a new CoinDealHistory object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="dealDate">Initial value of the DealDate property.</param>
 /// <param name="dealCompany">Initial value of the DealCompany property.</param>
 /// <param name="dealPrice">Initial value of the DealPrice property.</param>
 /// <param name="createDate">Initial value of the CreateDate property.</param>
 /// <param name="modifyDate">Initial value of the ModifyDate property.</param>
 /// <param name="coinId">Initial value of the CoinId property.</param>
 /// <param name="dealPriceUSD">Initial value of the DealPriceUSD property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 public static CoinDealHistory CreateCoinDealHistory(global::System.Guid id, global::System.DateTime dealDate, global::System.String dealCompany, global::System.Decimal dealPrice, global::System.DateTime createDate, global::System.DateTime modifyDate, global::System.Guid coinId, global::System.Decimal dealPriceUSD, global::System.String description)
 {
     CoinDealHistory coinDealHistory = new CoinDealHistory();
     coinDealHistory.Id = id;
     coinDealHistory.DealDate = dealDate;
     coinDealHistory.DealCompany = dealCompany;
     coinDealHistory.DealPrice = dealPrice;
     coinDealHistory.CreateDate = createDate;
     coinDealHistory.ModifyDate = modifyDate;
     coinDealHistory.CoinId = coinId;
     coinDealHistory.DealPriceUSD = dealPriceUSD;
     coinDealHistory.Description = description;
     return coinDealHistory;
 }
示例#5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the CoinDealHistories EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCoinDealHistories(CoinDealHistory coinDealHistory)
 {
     base.AddObject("CoinDealHistories", coinDealHistory);
 }
示例#6
0
        public ActionResult ModifyCoinHistory(CoinDealHistory coinDealHistory, 
            HttpPostedFileBase imageFile1,
            HttpPostedFileBase imageFile2,
            HttpPostedFileBase imageFile3,
            HttpPostedFileBase imageFile4)
        {
            coinDealHistory.Image1 = saveDealImage(imageFile1);
            coinDealHistory.Image2 = saveDealImage(imageFile2);
            coinDealHistory.Image3 = saveDealImage(imageFile3);
            coinDealHistory.Image4 = saveDealImage(imageFile4);

            CoinManager.ModifyCoinHistory(coinDealHistory);

            return RedirectToAction("Details", new { id = coinDealHistory.CoinId });
        }
示例#7
0
        public ActionResult Create(Coin coin, CoinDealHistory coinDealHistory, 
            HttpPostedFileBase imageFile1,
            HttpPostedFileBase imageFile2,
            HttpPostedFileBase imageFile3,
            HttpPostedFileBase imageFile4,
            string rate)
        {
            try
            {
                if (!String.IsNullOrEmpty(rate))
                {
                    HttpCookie myCookie = new HttpCookie("FYCoins");
                    myCookie["RateUSD"] = rate;
                    myCookie["DealDate"] = coinDealHistory.DealDate.ToString("yyyy-MM-dd");
                    myCookie["DealCompany"] = coinDealHistory.DealCompany;
                    myCookie.Expires = DateTime.Now.AddDays(365d);
                    Response.Cookies.Add(myCookie);
                }

                coin.Id = Guid.NewGuid();
                coin.CoinTypeId = 1;
                coin.Image = String.Empty;
                if (String.IsNullOrEmpty(coin.Description))
                    coin.Description = String.Empty;

                CoinManager.CreateCoin(coin);

                if (!String.IsNullOrWhiteSpace(coinDealHistory.DealCompany))
                {
                    coinDealHistory.CoinId = coin.Id;
                    coinDealHistory.Image1 = saveDealImage(imageFile1);
                    coinDealHistory.Image2 = saveDealImage(imageFile2);
                    coinDealHistory.Image3 = saveDealImage(imageFile3);
                    coinDealHistory.Image4 = saveDealImage(imageFile4);

                    CoinManager.CreateCoinDealHistory(coinDealHistory);
                }

                return RedirectToAction("Create", new { result = "保存成功" });
                //return RedirectToAction("Index");
            }
            catch (Exception e)
            {
                return RedirectToAction("Create", new { result = "保存失败:" + e.Message });
            }
        }