Beispiel #1
0
        //清除通知(已讀)
        public void ClearNotification(int senderId)
        {
            var notifylist = _context.Notifications.Where(n => n.MemberId == senderId && n.Checked == false).ToList();

            foreach (var item in notifylist)
            {
                item.Checked = true;
                _context.Update(item);
            }
            _context.SaveChanges();
        }
Beispiel #2
0
        //編輯開團內容
        public void EditGarbageOffer(int garbageServiceID, GarbageServiceOffer garbageServiceOffer)
        {
            var g = _context.GarbageServiceOffers.Where(n => n.GarbageServiceId == garbageServiceID).Select(n => new
            {
                n.L3available,
                n.L3maxCount,
                n.L5available,
                n.L5maxCount,
                n.L14available,
                n.L14maxCount,
                n.L25available,
                n.L25maxCount,
                n.L33available,
                n.L33maxCount,
                n.L75available,
                n.L75maxCount,
                n.L120available,
                n.L120maxCount,
            }).ToList();

            if (garbageServiceID == garbageServiceOffer.GarbageServiceId)
            {
                decimal[] s = cUtility.addressToLatlong(garbageServiceOffer.Address);
                garbageServiceOffer.Latitude      = s[0];
                garbageServiceOffer.Longitude     = s[1];
                garbageServiceOffer.L3available   = (byte)(g[0].L3available + (garbageServiceOffer.L3maxCount - g[0].L3maxCount));
                garbageServiceOffer.L5available   = (byte)(g[0].L5available + (garbageServiceOffer.L5maxCount - g[0].L5maxCount));
                garbageServiceOffer.L14available  = (byte)(g[0].L14available + (garbageServiceOffer.L14maxCount - g[0].L14maxCount));
                garbageServiceOffer.L25available  = (byte)(g[0].L25available + (garbageServiceOffer.L25maxCount - g[0].L25maxCount));
                garbageServiceOffer.L33available  = (byte)(g[0].L33available + (garbageServiceOffer.L33maxCount - g[0].L33maxCount));
                garbageServiceOffer.L75available  = (byte)(g[0].L75available + (garbageServiceOffer.L75maxCount - g[0].L75maxCount));
                garbageServiceOffer.L120available = (byte)(g[0].L120available + (garbageServiceOffer.L120maxCount - g[0].L120maxCount));
                _context.Update(garbageServiceOffer);
                _context.SaveChanges();
            }
        }
Beispiel #3
0
        public void editOrderOffer(int OrderId, Order order)
        {
            //取得被修改資料"修改前"的可購買數和購買上限
            var o = db.Orders.Where(n => n.OrderId == OrderId).Select(n => new { n.AvailableCount, n.MaxCount }).First();

            //計算團購修改後新的可購買數
            order.AvailableCount = (byte)(o.AvailableCount + (order.MaxCount - o.MaxCount));
            //取得新地址的經緯度
            decimal[] s = cUtility.addressToLatlong(order.Address);
            order.Latitude  = s[0];
            order.Longitude = s[1];
            //寫入資料庫
            db.Update(order);
            db.SaveChanges();
            //Console.WriteLine("A");
        }