コード例 #1
0
        /// <summary>
        /// 预下单记录
        /// </summary>
        /// <returns></returns>
        public static Result RecordPreRenewal(string account, string fileCoverId, string tradeNO)
        {
            Result result = new Result();

            try
            {
                PCBEntities pCBEntities    = new PCBEntities();
                Guid        fid            = new Guid(fileCoverId);
                var         pcborderTBlist = from order in pCBEntities.PCB_OrderTB
                                             where order.CreateAccount == account && order.FileCoverID == fid
                                             select order;
                if (pcborderTBlist.Count() > 0)
                {
                    pcborderTBlist.ToList()[0].UpdateDateTime = DateTime.Now;
                    pcborderTBlist.ToList()[0].OrderNumber    = tradeNO;

                    for (int i = 1; i < pcborderTBlist.Count(); i++)
                    {
                        pCBEntities.DeleteObject(pcborderTBlist.ToList()[i]);
                    }
                }
                else
                {
                    PCB_OrderTB orderTB = new PCB_OrderTB();
                    orderTB.OrderID        = System.Guid.NewGuid();
                    orderTB.CreateAccount  = account;
                    orderTB.CreateDateTime = DateTime.Now;
                    orderTB.FileCoverID    = fid;
                    orderTB.IsPay          = false;
                    orderTB.OrderNumber    = tradeNO;
                    orderTB.OrderPrice     = pCBEntities.PCB_FileCoverTB.FirstOrDefault(p => p.FileCoverID == fid).Price;
                    orderTB.UpdateDateTime = DateTime.Now;

                    pCBEntities.AddToPCB_OrderTB(orderTB);
                }
                result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges());
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(typeof(Common)).Info(ex.StackTrace);
                result.IsOK        = false;
                result.Description = ex.Message;
            }
            return(result);
        }