Exemplo n.º 1
0
        /// <summary>
        /// Shipper Delete
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        async public Task <string> DeleteShipper(Shipper item)
        {
            _Entity.Entry(item).State = EntityState.Deleted;
            foreach (var it in LookupTrading(new TradingQueryViewModel()
            {
                ShipperNo = item.TransNo,
                IsShipped = true
            }))
            {
                it.ShipperNo            = string.Empty;
                _Entity.Entry(it).State = EntityState.Modified;
            }

            bool success = await _Entity.SaveChangesAsync() > 0;

            return(success ? "刪除成功" : "刪除失敗");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Shipper Add
        /// </summary>
        /// <param name="item"></param>
        /// <param name="xPreData"></param>
        /// <returns></returns>
        async public Task <string> AddShipper(Shipper item, IEnumerable <Trading> xPreData)
        {
            item.TransNo = GetNewTransNo_Shipper(item);
            _Entity.Entry(item).State = EntityState.Added;

            if (xPreData.IsEmpty())
            {
                return("請確認欲出貨之交易");
            }
            foreach (var it in xPreData)
            {
                it.ShipperNo            = item.TransNo;
                _Entity.Entry(it).State = EntityState.Modified;
            }

            bool success = await _Entity.SaveChangesAsync() > 0;

            return(success ? "新增成功" : "新增失敗");
        }
Exemplo n.º 3
0
        private string GetNewTransNo_Shipper(Shipper item)
        {
            ///S20171007001
            string xNewTransNo = string.Format("S{0}", item.TradeDate.ToString("yyyyMMdd"));
            int    xNewNo      = 1;
            var    xData       = LookupShipper(new ShipperQueryViewModel()
            {
                TradeDate_S = item.TradeDate,
                TradeDate_E = item.TradeDate
            })
                                 .Where(w => w.TransNo.StartsWith(xNewTransNo))
                                 .OrderByDescending(o => o.TransNo)
                                 .FirstOrDefault();

            if (xData != null)
            {
                xNewNo = int.Parse(xData.TransNo.Substring(xData.TransNo.Length - 3)) + 1;
            }

            return(string.Concat(xNewTransNo, xNewNo.ToString("000")));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Shipper Update
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 async public Task <string> UpdateShipper(Shipper item)
 {
     return(await Save <Shipper>(EntityState.Modified, item));
 }