Beispiel #1
0
        public IActionResult Join(GarbageServiceUseRecord r)
        {
            ////未登入只能搜尋服務,不能使用(加入),若按下加入會跳轉登入頁
            if (HttpContext.Session.GetInt32(cUtility.Current_User_Id) == null)
            {
                return(RedirectToAction("Login", "Member", new { from = "ServiceUse/Index" }));
            }
            //填入使用者id到使用紀錄
            r.MemberId = HttpContext.Session.GetInt32(cUtility.Current_User_Id).Value;
            //取得被使用服務
            var offer = db.GarbageServiceOffers.Where(o => o.GarbageServiceId == r.GarbageServiceOfferId).First();

            //some testing here need to be done
            //將被使用服務的可用袋數減去被使用袋數
            offer.L3available   -= r.L3count;
            offer.L5available   -= r.L5count;
            offer.L14available  -= r.L14count;
            offer.L25available  -= r.L25count;
            offer.L33available  -= r.L33count;
            offer.L75available  -= r.L75count;
            offer.L120available -= r.L120count;
            //加入使用紀錄,將修改寫入資料庫
            db.Add(r);
            db.SaveChanges();
            //傳到新加入服務團的聊天室頁面
            return(RedirectToAction("Index", "ChatMessageRecords", new { grouptype = 2, groupid = r.GarbageServiceOfferId }));
        }
Beispiel #2
0
        //編輯加團內容
        public void EditServiceUse(int garbageServiceID, GarbageServiceUseRecord garbageServiceUseRecord)
        {
            var g = db.GarbageServiceUseRecords.Where(n => n.GarbageServiceOfferId == garbageServiceID).Select(n => new
            {
            }).ToList();

            //if (garbageServiceID == garbageServiceUseRecord.GarbageServiceId)
            //{
            //    decimal[] s = cUtility.addressToLatlong(garbageServiceUseRecord.Address);
            //    garbageServiceUseRecord.Latitude = s[0];
            //    garbageServiceUseRecord.Longitude = s[1];
            //    garbageServiceUseRecord.L3available = (byte)(g[0].L3available + (garbageServiceUseRecord.L3maxCount - g[0].L3maxCount));
            //    garbageServiceUseRecord.L5available = (byte)(g[0].L5available + (garbageServiceUseRecord.L5maxCount - g[0].L5maxCount));
            //    garbageServiceUseRecord.L14available = (byte)(g[0].L14available + (garbageServiceUseRecord.L14maxCount - g[0].L14maxCount));
            //    garbageServiceUseRecord.L25available = (byte)(g[0].L25available + (garbageServiceUseRecord.L25maxCount - g[0].L25maxCount));
            //    garbageServiceUseRecord.L33available = (byte)(g[0].L33available + (garbageServiceUseRecord.L33maxCount - g[0].L33maxCount));
            //    garbageServiceUseRecord.L75available = (byte)(g[0].L75available + (garbageServiceUseRecord.L75maxCount - g[0].L75maxCount));
            //    garbageServiceUseRecord.L120available = (byte)(g[0].L120available + (garbageServiceUseRecord.L120maxCount - g[0].L120maxCount));
            //    db.Update(garbageServiceUseRecord);
            //    db.SaveChanges();
            //}
        }
Beispiel #3
0
 public GarbageServiceUseRecordsViewModel(GarbageServiceUseRecord q)
 {
     garbageServiceUseRecord = q;
 }