public ActionResult CreateAndEdit(PackageTourViewModel obj)
        {
            try
            {
                Validate(obj);
                if (ModelState.IsValid)
                {
                    Mapper.CreateMap<PackageTourViewModel, PackageTour>();
                    var objSave = Mapper.Map<PackageTour>(obj);
                    objSave.TitleUrl = new BaseController().RewriteTitle(obj.TourName);
                    db.PackageTours.Add(objSave);

                    if (obj.TourId > 0)
                    {
                        db.Entry(objSave).State = EntityState.Modified;
                    }

                    db.SaveChanges();

                    return RedirectToAction("AllPackageTour");
                }
                obj.LstTourStyle = db.ReferenceValues.Where(o => o.ReferenceId == ReferenceId.TourStyle).ToList();
                return View("Addnewtour", obj);
            }
            catch (Exception ex)
            {
                obj.Message = ex.ToString();
                return JavaScript("<script>alert(\"" + obj.Message + "\")</script>");
            }
        }
 public ActionResult Addnewtour()
 {
     var objView = new PackageTourViewModel()
     {
         LstTourStyle = db.ReferenceValues.Where(o => o.ReferenceId == ReferenceId.TourStyle).ToList(),
         lstArears = db.ReferenceValues.Where(o => o.ReferenceId == ReferenceId.Areas).ToList()
     };
     return View(objView);
 }
 private void Validate(PackageTourViewModel obj)
 {
     ModelState.Clear();
     if (string.IsNullOrEmpty(obj.TourName))
         ModelState.AddModelError("TourName", "Tour Name is required !");
 }
        public ActionResult Edit(int id)
        {
            try
            {
                var objPackageTour = db.PackageTours.First(o => o.TourId == id);
                var objPackageTourViewModel = new PackageTourViewModel()
                {
                    TourId = objPackageTour.TourId,
                    TourName = objPackageTour.TourName,
                    Duration = objPackageTour.Duration,
                    TourRoute = objPackageTour.TourRoute,
                    TourStyle = objPackageTour.TourStyle,
                    ActivityLevel = objPackageTour.ActivityLevel,
                    Date = objPackageTour.Date,
                    SortDescription = objPackageTour.SortDescription,
                    Detail = objPackageTour.Detail,
                    AgencyStandard2 = objPackageTour.AgencyStandard2,
                    AgencyStandard35 = objPackageTour.AgencyStandard35,
                    AgencyStandard69 = objPackageTour.AgencyStandard69,
                    AgencySuperior2 = objPackageTour.AgencySuperior2,
                    AgencySuperior35 = objPackageTour.AgencySuperior35,
                    AgencySuperior69 = objPackageTour.AgencySuperior69,
                    Agency2Standard2 = objPackageTour.Agency2Standard2,
                    Agency2Standard35 = objPackageTour.Agency2Standard35,
                    Agency2Standard69 = objPackageTour.Agency2Standard69,
                    Agency2Superior2 = objPackageTour.Agency2Superior2,
                    Agency2Superior35 = objPackageTour.Agency2Superior35,
                    Agency2Superior69 = objPackageTour.Agency2Superior69,
                    GuestStandard2 = objPackageTour.GuestStandard2,
                    GuestStandard35 = objPackageTour.GuestStandard35,
                    GuestStandard69 = objPackageTour.GuestStandard69,
                    GuestSuperior2 = objPackageTour.GuestSuperior2,
                    GuestSuperior35 = objPackageTour.GuestSuperior35,
                    GuestSuperior69 = objPackageTour.GuestSuperior69,
                    AgencyDeluxe2 = objPackageTour.AgencyDeluxe2,
                    AgencyDeluxe35 = objPackageTour.AgencyDeluxe35,
                    AgencyDeluxe69 = objPackageTour.AgencyDeluxe69,
                    Agency2Deluxe2 = objPackageTour.Agency2Deluxe2,
                    Agency2Deluxe35 = objPackageTour.Agency2Deluxe35,
                    Agency2Deluxe69 = objPackageTour.Agency2Deluxe69,
                    GuestDeluxe2 = objPackageTour.GuestDeluxe2,
                    GuestDeluxe35 = objPackageTour.GuestDeluxe35,
                    GuestDeluxe69 = objPackageTour.GuestDeluxe69,
                    Agency1SingleSupplementStandard = objPackageTour.Agency1SingleSupplementStandard,
                    Agency1SingleSupplementSuperior = objPackageTour.Agency1SingleSupplementSuperior,
                    Agency1SingleSupplementDeluxe = objPackageTour.Agency1SingleSupplementDeluxe,
                    Agency2SingleSupplementStandard = objPackageTour.Agency2SingleSupplementStandard,
                    Agency2SingleSupplementSuperior = objPackageTour.Agency2SingleSupplementSuperior,
                    Agency2SingleSupplementDeluxe = objPackageTour.Agency2SingleSupplementDeluxe,
                    GuestSingleSupplementStandard = objPackageTour.GuestSingleSupplementStandard,
                    GuestSingleSupplementSuperior = objPackageTour.GuestSingleSupplementSuperior,
                    GuestSingleSupplementDeluxe = objPackageTour.GuestSingleSupplementDeluxe,
                    Special = objPackageTour.Special,
                    Image = objPackageTour.Image,
                    Areas = objPackageTour.Areas,
                    Sort = objPackageTour.Sort,
                    LstTourStyle = db.ReferenceValues.Where(o => o.ReferenceId == ReferenceId.TourStyle).ToList(),
                    lstArears = db.ReferenceValues.Where(o => o.ReferenceId == ReferenceId.Areas).ToList(),

                };
                return View("Addnewtour", objPackageTourViewModel);

            }
            catch (Exception ex)
            {

                throw new System.ArgumentException(ex.Message);
            }
        }