Esempio n. 1
0
        public async Task <ActionResult <CActivity> > PostCActivity(CActivity cActivity)
        {
            _context.CActivity.Add(cActivity);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCActivity", new { id = cActivity.Id }, cActivity));
        }
Esempio n. 2
0
        public async Task <IActionResult> PutCActivity(int id, CActivity cActivity)
        {
            if (id != cActivity.Id)
            {
                return(BadRequest());
            }

            _context.Entry(cActivity).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CActivityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 3
0
        public abstract CActivity SortList(string condition); //活動列表+排序


        public CActivity GetLikeList(CActivity theList, int memberID)
        {
            var memberLikeList = GetMemberData(memberID, "f會員收藏的活動編號");

            if (!string.IsNullOrEmpty(memberLikeList))
            {
                theList.MemberLike = memberLikeList.Split(',');
            }
            return(theList);
        }
Esempio n. 4
0
        // GET: Edit
        public ActionResult Edit(int id)
        {
            Activity table = (new SingleApartmentEntities()).Activity.FirstOrDefault(p => p.ActivityID == id);

            if (table == null)
            {
                return(RedirectToAction("List"));
            }
            CActivity tb = new CActivity()
            {
                entity = table
            };

            return(View(tb));
        }
        //暫存到購物車
        public ActionResult AddToCart_Session(int id)
        {
            SingleApartmentEntities db = new SingleApartmentEntities();
            Activity table             = db.Activity.FirstOrDefault(p => p.ActivityID == id);

            if (table == null)
            {
                return(RedirectToAction("List"));
            }
            CActivity CA = new CActivity()
            {
                entity = table
            };

            return(View(CA));
        }
Esempio n. 6
0
        public override CActivity SortList(string condition)
        {
            int       totalPage, nowPage;
            CActivity returnValue  = new CActivity();
            CSelect   obj          = CSelectDeserialize(condition);
            var       order        = typeof(tActivity).GetProperty(obj.Order);//使用映射動態抓取排序條件
            var       activityList = db.tActivity.AsEnumerable()
                                     .Where(t => t.f活動類型 == "旅遊").Select(t => t);

            activityList = (obj.BackgroundColor == "rgb(250, 224, 178)")
                ? activityList.OrderByDescending(t => order.GetValue(t, null)) //降冪
                : activityList.OrderBy(t => order.GetValue(t, null));          //升冪

            if (!string.IsNullOrEmpty(obj.Contain))                            //搜尋欄位若非空
            {
                activityList = activityList.Where(t => t.f活動標題.Contains(obj.Contain));
            }

            if (obj.Category != "所有")
            {
                activityList = activityList.Where(t => t.f活動分類 == obj.Category);
            }

            if (obj.Label != "全部")
            {
                activityList = activityList.Where(t => t.f活動讚數 > Convert.ToInt32(obj.Label));
            }

            //頁數判斷
            totalPage = (activityList.Count() % 4 == 0 && activityList.Count() != 0)
                ? activityList.Count() / 4
                : (activityList.Count() - activityList.Count() % 4) / 4 + 1;

            nowPage = (obj.Page == 0 || obj.Page > totalPage) ? 1 : obj.Page;

            activityList = activityList.Skip(4 * (nowPage - 1)).Take(4);

            returnValue.FinalList = activityList;
            returnValue.TotalPage = totalPage;
            returnValue.NowPage   = nowPage;
            return(returnValue);
        }
Esempio n. 7
0
        public JsonResult adnewactivity(string ActivityName, int cby)
        {
            var m = db.CActivity.Where(x => x.ActivityName == ActivityName).Any();

            if (m)
            {
                return(Json(new { Success = false, Message = "هذا الاسم    " + ActivityName + " مستخدم من قبل    " }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                CActivity cmp = new CActivity();
                string    ip  = HttpContext.Request.UserHostAddress;
                string    md  = Request.UserHostName;
                cmp.ActivityName = ActivityName;
                cmp.CreateDate   = DateTime.Now;
                cmp.CreateBy     = cby;
                cmp.IsActive     = true;
                cmp.CreatedHost  = ip;
                cmp.CreatedIP    = md;
                db.CActivity.Add(cmp);
                db.SaveChanges();
            }
            return(Json(new { Success = true, Message = "تمت إضافة نشاط    " + ActivityName + " بنجاح    " }, JsonRequestBehavior.AllowGet));
        }