示例#1
0
        public ActionResult UserDonate(int donateId, int money)
        {
            var user = Request.Cookies[MessageConst.USER_LOGIN];

            if (user == null)
            {
                TempData[MessageConst.ERROR] = "Please login to donate!";
                return(RedirectToAction("Index", "Login"));
            }
            var data       = JsonConvert.DeserializeObject <UserLogin>(user.Value);
            var donateInfo = new DonateDao(_provider).GetById(donateId);
            var orderData  = new OrderData()
            {
                DonateName = donateInfo.DonateName,
                Money      = money,
                UserMail   = data.UserMail,
                DonateId   = donateInfo.ID,
                UserName   = data.UserName
            };

            Session[MessageConst.USER_SESSION] = orderData;
            if (donateInfo != null && data != null)
            {
                return(RedirectToAction("PaymentWithPaypal", "Home"));
            }

            return(RedirectToAction("Donate"));
        }
示例#2
0
        //Donate Infomation Page
        public ActionResult DonateInformation(int id)
        {
            var data = new DonateDao(_provider).GetById(id);

            ViewBag.DonateInfo = data;
            return(View());
        }
示例#3
0
        public ActionResult Edit(int id)
        {
            ViewBag.Categories = new CategoryDao(_unitOfWork).GetAll();
            var data = new DonateDao(_unitOfWork).GetByid(id);

            if (data == null)
            {
                return(RedirectToAction("Page404", "Error"));
            }
            return(View(data));
        }
示例#4
0
        //method hide donate
        public ActionResult HideDonate(int id)
        {
            var lsUD   = new DonateDao(_unitOfWork).GetById(id).UserDonates.Count;
            var donate = new DonateDao(_unitOfWork).GetById(id);

            if (lsUD > 0 && (donate.DonateStatus == DonateStatus.Ongoing || donate.DonateStatus == DonateStatus.Upcoming))
            {
                TempData[MessageConst.ERROR] = "Can't hide, because this had some donate by user";
                return(RedirectToAction("Index"));
            }
            new DonateDao(_unitOfWork).HideDonate(id);
            TempData[MessageConst.SUCCESS] = "Hide/Unhide Successfully !";
            return(RedirectToAction("Index"));
        }
示例#5
0
        public ActionResult Edit(DonateDTO donate)
        {
            var data = new DonateDao(_unitOfWork).GetByid(donate.ID);

            ViewBag.Categories = new CategoryDao(_unitOfWork).GetAll();
            if (DateTime.Parse(donate.EndDay.ToString("yyyy/MM/dd")) < DateTime.Parse(donate.StartDay.ToString("yyyy/MM/dd")))
            {
                TempData[MessageConst.ERROR] = "Date time is invalid";
                return(View(data));
            }

            if (!ModelState.IsValid)
            {
                return(View(data));
            }

            if (new DonateDao(_unitOfWork).Edit(donate))
            {
                TempData[MessageConst.SUCCESS] = "Update Successfully !";
                return(RedirectToAction("Index"));
            }
            TempData[MessageConst.ERROR] = "Update Failed";
            return(View(data));
        }