Exemplo n.º 1
0
        public ActionResult Create(Voucher voucher)
        {
            using (var db = new WishoianContext())
            {
                if (ModelState.IsValid)
                {
                    voucher.VoucherId = Guid.NewGuid();
                    if (Request.Files.Count > 0)
                    {
                        var hpf = Request.Files[0];
                        if (hpf.ContentLength > 0)
                        {
                            string type = Utility.GetImgeType(hpf.ContentType);
                            string fileName = string.Format("{0}\\{1}.{2}", Server.MapPath("~/WebUpload"), voucher.VoucherId, type);
                            hpf.SaveAs(fileName);
                            voucher.ImageUrl = string.Format("{0}.{1}", voucher.VoucherId, type);
                        }
                    }
                    db.Vouchers.Add(voucher);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }

                return View(voucher);
            }
        }
Exemplo n.º 2
0
 //
 // GET: /Vourcher/Delete/5
 public ActionResult Delete(Guid id)
 {
     using (var db = new WishoianContext())
     {
         Voucher voucher = db.Vouchers.Find(id);
         return View(voucher);
     }
 }
Exemplo n.º 3
0
 public ActionResult DeleteConfirmed(Guid id)
 {
     using (var db = new WishoianContext())
     {
         Voucher voucher = db.Vouchers.Find(id);
         db.Vouchers.Remove(voucher);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
 }
Exemplo n.º 4
0
 //
 // GET: /Vourcher/Details/5
 public ViewResult Details(Guid id)
 {
     using (var db = new WishoianContext())
     {
         Voucher voucher = db.Vouchers.Find(id);
         return View(voucher);
     }
 }
Exemplo n.º 5
0
        public ViewResult ViewTourDetail(Guid tourPlanId)
        {
            using (var db = new WishoianContext())
            {
                var tourPlan = db.TourPlans.Find(tourPlanId);
                if (tourPlan != null)
                {
                    // Set up our ViewModel
                    var viewModel = new TourPlanDetailViewModel
                    {
                        Tour = new TourDetailViewModel() { Tour = tourPlan.Tour, SpecialTourPlan = tourPlan },
                        TourSchedules = tourPlan.Tour.TourSchedules.OrderBy(s => s.IndexDay).ToList(),
                        TourPlan = tourPlan
                    };

                    // Update View
                    db.Entry(tourPlan).State = EntityState.Modified;
                    if (tourPlan.Viewed == null)
                        tourPlan.Viewed = 1;
                    else

                        tourPlan.Viewed += 1;
                    db.SaveChanges();
                    return View(viewModel);

                }
                return View();
            }
        }
Exemplo n.º 6
0
        public ActionResult ViewFavouriteTours()
        {
            using (var db = new WishoianContext())
            {
                var restult = new List<TourPlanDetailViewModel>();
                var tourPlan = db.TourPlans.Take(5).ToList().OrderByDescending(t => t.Viewed);
                foreach (var item in tourPlan)
                {
                    var viewModel = new TourPlanDetailViewModel
                    {
                        Tour = new TourDetailViewModel() { Tour = item.Tour, SpecialTourPlan = item },
                        TourSchedules = item.Tour.TourSchedules.OrderBy(s => s.IndexDay).ToList(),
                        TourPlan = item
                    };
                    restult.Add(viewModel);
                }
                // Set up our ViewModel

                return PartialView(restult);
            }
        }
Exemplo n.º 7
0
        public ViewResult SearchTour(TourSearchViewModel search)
        {
            var lst = new List<TourPlanDetailViewModel>();
            using (var db = new WishoianContext())
            {
                var tourPlan = db.TourPlans.Where(t =>
                    t.Tour.TourType.TypeName == search.TourTypeName
                    && ((search.OpenDate == null) || t.OpenDate >= search.OpenDate)
                    && (search.StartLocationId == t.Tour.StartLocationId && (search.EndLocationId == null || search.EndLocationId.Value == t.Tour.EndLocationId))
                    ).ToList();

                foreach (var item in tourPlan)
                {
                    // Set up our ViewModel
                    var viewModel = new TourPlanDetailViewModel
                    {
                        Tour = new TourDetailViewModel() { Tour = item.Tour, SpecialTourPlan = item },
                        TourSchedules = item.Tour.TourSchedules.OrderBy(s => s.IndexDay).ToList(),
                        TourPlan = item
                    };
                    lst.Add(viewModel);
                }

                return View(lst);
            }
        }